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. This field is added automatically - but this behavior can be overridden
iregex
id field
none()
clear() method
2. Lookup type that returns results with a case-insensitive start sequence.
istartswith
gte
QuerySet
get(**kwargs)
3. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
lt
iteration
get_absolute_url()
iterator()
4. This query finds all entries with an id in the list [1 - 3 - 4]
search
blank
related_name
Entry.objects.filter(id__in=[1 - 3 - 4])
5. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model
year
month
Proxy model
istartswith
6. This is a criterion that narrow down a QuerySet based on given parameters.
filter
many-to-one relationship
__unicode__()
related_name
7. This method immediately deletes the object and has no return value.
regex
delete()
filter(**kwargs)
Proxy model
8. Fields are specified by these
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
class attributes
all()
annotate(args - *kwargs)
9. Performs an SQL delete query on all rows in the QuerySet. This method is applied instantly. You cannot call this method on a QuerySet that has had a slice taken or can otherwise no longer be filtered.
delete()
update()
aggregate(args - *kwargs)
ordered
10. Lookup type that returns results greater than a given value.
gt
related_name
db
Abstract base class
11. The default for this is the name of the child class followed by '_set'.
reverse name
QuerySet
lte
get(**kwargs)
12. 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
Many-to-many relationship to self
Restrictions on field names
iendswith
through argument
13. 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.
primary_key
all()
intermediate models
Many-to-many relationship through an intermediate model
14. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F
save()
Entry.objects.filter(id__in=[1 - 3 - 4])
update(**kwargs)
gt
15. 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.
year
unique
values_list(*fields)
one-to-one relationship
16. Returns a QuerySet that will automatically "follow" foreign-key relationships - selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later u
Q(question__istartswith='What')
reverse()
Meta class
select_related()
17. Conjuntion operator for Q objects.
db
==
Multi-table inheritance
&
18. Lookup type that returns results greater than or equal to a given value.
gte
distinct()
reverse name
class type
19. Returns a new QuerySet containing objects that match the given lookup parameters.
lt
in_bulk(id_list)
Abstract base class
filter(**kwargs)
20. This model method is used for updating a ManyToManyField.
choices tuple
QuerySet
add()
get(**kwargs)
21. Used to get a QuerySet for a model. This is called 'objects' by default.
iendswith
add()
Manager
pickling
22. Lookup type that returns results with a case-insensitive end sequence.
id field
Q()
iendswith
gt
23. Exception raised by get(**kwargs) if no items match the query.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
DoesNotExist
reverse name
save()
24. Evaluates the QuerySet (by performing the query) and returns an iterator over the results. A QuerySet typically caches its results internally so that repeated evaluations do not result in additional queries; this method will instead read results dire
iterator()
isnull
get(**kwargs)
Proxy model
25. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
week_day
default
iregex
26. A convenience method for looking up an object with the given kwargs - creating one if necessary.
endswith
order_by(*fields)
get_or_create(**kwargs)
filter(**kwargs)
27. If this option is True - Django will store empty values as NULL in the database. Default is False.
unique
null
class attributes
Field lookups
28. 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.
none()
create(**kwargs)
pickling
add()
29. 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.
reverse()
clear() method
get(**kwargs)
none()
30. Can be used to remove all many-to-many relationships for an instance
regex
save()
in
clear() method
31. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
db
filter(**kwargs)
exists()
values(*fields)
32. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.
Multi-table inheritance
reverse name
gt
class type
33. A Python "magic method" that returns a unicode "representation" of any object.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
distinct()
__unicode__()
~
34. A convenience method for constructing an object and saving it all in one step.
lt
create(**kwargs)
none()
Custom model methods
35. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
iterator()
many-to-many relationship
iteration
reverse()
36. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
many-to-many relationship
related_name
range
Field lookups
37. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
exclude(**kwargs)
default
Many-to-many relationship through an intermediate model
38. Defines a many-to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
isnull
ForeignKey
39. 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.
defer(*fields)
delete()
update()
day
40. Lookup type that returns results with a case-sensitive end sequence.
choices tuple
add()
endswith
many-to-one relationship
41. 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
Abstract base class
none()
Q()
Entry.objects.filter(pub_date__range=(start_date - end_date))
42. 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
Custom model methods
blank
intermediate models
aggregate(args - *kwargs)
43. Takes a list of primary-key values and returns a dictionary mapping each primary-key value to an instance of the object with the given ID.
iteration
using(alias)
Many-to-many relationship through an intermediate model
in_bulk(id_list)
44. To activate your models
ForeignKey
Meta class
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
day
45. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.
ForeignKey
pk
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
order_by(*fields)
46. Adds to each object in the QuerySet with the provided list of aggregate values (averages - sums - etc) that have been computed over the objects that are related to the objects in the QuerySet. Each argument to this is content that will be added to ea
Entry.objects.filter(pub_date__range=(start_date - end_date))
evaluation
annotate(args - *kwargs)
reverse()
47. 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
db
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
range
48. 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.
&
Abstract base class
reverse()
exact
49. In some complex data-modeling situations - your models might contain a lot of fields - some of which could contain a lot of data (for example - text fields) - or require expensive processing to convert them to Python objects. If you are using the res
Multi-table inheritance
defer(*fields)
istartswith
db
50. 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.
unique
pickling
order_by(*fields)
evaluation
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