SUBJECTS
|
BROWSE
|
CAREER CENTER
|
POPULAR
|
JOIN
|
LOGIN
Business Skills
|
Soft Skills
|
Basic Literacy
|
Certifications
About
|
Help
|
Privacy
|
Terms
|
Email
Search
Test your basic knowledge |
Django Queryset
Start Test
Study First
Subject
:
it-skills
Instructions:
Answer 50 questions in 15 minutes.
If you are not ready to take this test, you can
study here
.
Match each statement with the correct term.
Don't refresh. All questions and answers are randomly picked and ordered every time you load a test.
This is a study tool. The 3 wrong answers for each question are randomly chosen from answers to other questions. So, you might find at times the answers obvious, but you will see it re-enforces your understanding as you take the test each time.
1. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
Proxy model
id field
Field lookups
through argument
2. Lookup type that returns results with a case-insensitive start sequence.
lte
aggregate(args - *kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
istartswith
3. Defines a many-to-many relationship. You use it just like any other Field type: by including it as a class attribute of your model.
ManyToManyField
slicing
Entry.objects.filter(id__in=[1 - 3 - 4])
delete()
4. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.
only(*fields)
many-to-one relationship
Many-to-many relationship to self
iterator()
5. These are "anything that's not a field" - such as ordering options (ordering) - database table name (db_table) - or human-readable singular and plural names (verbose_name and verbose_name_plural)
Model metadata
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
filter(**kwargs)
Q()
6. Here - you can't use add - create - or assignment (i.e. - beatles.members = [...]) to create relationships. You need to specify all the detail for the relationship required by the intermediate model.
update(**kwargs)
month
Many-to-many relationship through an intermediate model
help_text
7. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r
iteration
filter(**kwargs)
startswith
intermediate models
8. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.
Entry.objects.filter(id__gt=4)
clear() method
QuerySet
Q()
9. Keyword shortcut for looking up an object by primary key.
pk
~
istartswith
iexact
10. Negation operator for Q objects.
~
class type
update()
exact
11. If you pickle a QuerySet - this will force all the results to be loaded into memory prior to pickling. When you unpickle a QuerySet - it contains the results at the moment it was pickled - rather than the results that are currently in the database.
pickling
Q()
Entry.objects.filter(pub_date__year=2005).delete()
day
12. This object allows you to compare the value of a model field with another field on the same model. Django supports the use of addition - subtraction - multiplication - division and modulo arithmetic with these objects - both with constants and with o
primary_key
order_by(*fields)
delete()
F()
13. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo
Multi-table inheritance
none()
latest(field_name=None)
class type
14. Can be used to remove all many-to-many relationships for an instance
clear() method
year
all()
day
15. A manager method which returns a single object. If there are no results that match the query - this method will raise a DoesNotExist exception. If more than one item matches this query - the method will raise MultipleObjectsReturned.
many-to-many relationship
endswith
iterator()
get(**kwargs)
16. Conjuntion operator for Q objects.
add()
get_absolute_url()
&
Q(question__istartswith='What')
17. The value given in the absence of a specified value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created.
default
Entry.objects.filter(pub_date__range=(start_date - end_date))
in_bulk(id_list)
day
18. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
Field lookups
values(*fields)
all()
Entry.objects.filter(id__gt=4)
19. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
DoesNotExist
endswith
Proxy model
20. Returns the most recent object in the table - by date - using the field_name provided as the date field.
choices
latest(field_name=None)
ForeignKey
gte
21. This query deletes all Entry objects with a pub_date year of 2005.
primary_key
Entry.objects.filter(pub_date__year=2005).delete()
order_by(*fields)
isnull
22. This method immediately deletes the object and has no return value.
choices tuple
delete()
class attributes
endswith
23. This query finds all entries between a start date of start_date and an end date of end_date.
Many-to-many relationship through an intermediate model
Custom model methods
create(**kwargs)
Entry.objects.filter(pub_date__range=(start_date - end_date))
24. Returns a copy of the current QuerySet (or QuerySet subclass you pass in). This can be useful in some situations where you might want to pass in either a model manager or a QuerySet and do further filtering on the result. You can safely call all() on
week_day
when you add new apps to INSTALLED_APPS
Meta class
all()
25. Lookup type that finds a case-sensitive regular expression match.
__unicode__()
regex
month
primary_key
26. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.
intermediate models
search
iregex
unique
27. Lookup type that returns results with a case-sensitive end sequence.
get(**kwargs)
Many-to-many relationship through an intermediate model
lt
endswith
28. Lookup type that yields a case-insensitive match.
relationship spanning
iexact
Model metadata
F()
29. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
db
exact
month
30. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
31. Lookup type that returns results with a case-insensitive end sequence.
iterator()
Entry.objects.filter(id__gt=4)
Entry.objects.filter(pub_date__range=(start_date - end_date))
iendswith
32. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.
in
choices
many-to-many relationship
update()
33. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.
distinct()
choices tuple
get_or_create(**kwargs)
iendswith
34. Lookup type that returns results in a given list.
in
select_related()
clear() method
lt
35. This class type is useful when you just want to use the parent class to hold information that you don't want to have to type out for each child model. This class isn't going to ever be used in isolation. When it is used as a base class for other mode
startswith
default
reverse name
Abstract base class
36. A convenience method for looking up an object with the given kwargs - creating one if necessary.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
delete()
Meta class
get_or_create(**kwargs)
37. The default for this is the name of the child class followed by '_set'.
reverse name
select_related()
through argument
Restrictions on field names
38. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
relationship spanning
iteration
many-to-many relationship
isnull
39. Lookup type that returns results less than or equal to a given value.
lte
pickling
clear() method
through argument
40. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
values_list(*fields)
choices tuple
year
related_name
41. This method returns tuples of values when iterated over. Each tuple contains the value from the respective field passed into the call to this method -- so the first item is the first field - etc.
aggregate(args - *kwargs)
pickling
values_list(*fields)
evaluation
42. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Custom model methods
iterator()
model
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
43. Specifies the model that will be used to govern the many-to-many relationship. You can then put extra fields on the intermediate model. The intermediate model is associated with the ManyToManyField using this to point to the model that will act as an
through argument
filter(**kwargs)
in
F()
44. Returns a dictionary of aggregate values (averages - sums - etc) calculated over the QuerySet. Each argument to this method specifies a value that will be included in the dictionary that is returned.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
all()
aggregate(args - *kwargs)
Many-to-many relationship through an intermediate model
45. This represents a collection of objects from your database. It can have zero - one or many filters.
Proxy model
OneToOneField
QuerySet
exists()
46. By default - results returned by a QuerySet are ordered by the ordering tuple given by the ordering option in the model's Meta. You can override this on a per-QuerySet basis by using the this method.
order_by(*fields)
get(**kwargs)
save()
delete()
47. Lookup type that finds a case-insensitive regular expression match.
DoesNotExist
iregex
delete()
istartswith
48. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.
choices
choices tuple
one-to-one relationship
none()
49. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
reverse name
one-to-one relationship
many-to-many relationship
F()
50. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
Sorry!:) No result found.
Can you answer 50 questions in 15 minutes?
Let me suggest you:
Browse all subjects
Browse all tests
Most popular tests
Major Subjects
Tests & Exams
AP
CLEP
DSST
GRE
SAT
GMAT
Certifications
CISSP go to https://www.isc2.org/
PMP
ITIL
RHCE
MCTS
More...
IT Skills
Android Programming
Data Modeling
Objective C Programming
Basic Python Programming
Adobe Illustrator
More...
Business Skills
Advertising Techniques
Business Accounting Basics
Business Strategy
Human Resource Management
Marketing Basics
More...
Soft Skills
Body Language
People Skills
Public Speaking
Persuasion
Job Hunting And Resumes
More...
Vocabulary
GRE Vocab
SAT Vocab
TOEFL Essential Vocab
Basic English Words For All
Global Words You Should Know
Business English
More...
Languages
AP German Vocab
AP Latin Vocab
SAT Subject Test: French
Italian Survival
Norwegian Survival
More...
Engineering
Audio Engineering
Computer Science Engineering
Aerospace Engineering
Chemical Engineering
Structural Engineering
More...
Health Sciences
Basic Nursing Skills
Health Science Language Fundamentals
Veterinary Technology Medical Language
Cardiology
Clinical Surgery
More...
English
Grammar Fundamentals
Literary And Rhetorical Vocab
Elements Of Style Vocab
Introduction To English Major
Complete Advanced Sentences
Literature
Homonyms
More...
Math
Algebra Formulas
Basic Arithmetic: Measurements
Metric Conversions
Geometric Properties
Important Math Facts
Number Sense Vocab
Business Math
More...
Other Major Subjects
Science
Economics
History
Law
Performing-arts
Cooking
Logic & Reasoning
Trivia
Browse all subjects
Browse all tests
Most popular tests