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. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
Entry.objects.filter(pub_date__year=2005).delete()
clear() method
isnull
delete()
2. 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.
in_bulk(id_list)
distinct()
exact
get(**kwargs)
3. 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.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
MultipleObjectsReturned
Entry.objects.filter(id__in=[1 - 3 - 4])
Entry.objects.filter(pub_date__range=(start_date - end_date))
4. Manager method used to retrieve every object in a model.
clear() method
Entry.objects.filter(pub_date__year=2005).delete()
none()
all()
5. 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
filter(**kwargs)
aggregate(args - *kwargs)
ForeignKey
iterator()
6. Lookup type that returns results with a case-sensitive start sequence.
in
pk
startswith
==
7. Lookup type that returns results less than or equal to a given value.
lte
regex
Many-to-many relationship through an intermediate model
get(**kwargs)
8. These methods are intended to do "table-wide" things.
iteration
model
delete()
Manager methods
9. 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
blank
istartswith
Entry.objects.filter(id__gt=4)
through argument
10. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
Field lookups
__unicode__()
day
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
11. Fields are specified by these
startswith
class attributes
filter(**kwargs)
iregex
12. 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.
update()
annotate(args - *kwargs)
using(alias)
iexact
13. Can be used to remove all many-to-many relationships for an instance
all()
clear() method
endswith
id field
14. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
15. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
only(*fields)
get(**kwargs)
Model metadata
16. This method is for controlling which database the QuerySet will be evaluated against if you are using more than one database. The only argument this method takes is the alias of a database - as defined in DATABASES.
using(alias)
when you add new apps to INSTALLED_APPS
regex
get_or_create(**kwargs)
17. This is a criterion that narrow down a QuerySet based on given parameters.
Manager methods
filter
Restrictions on field names
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
18. Lookup type that returns results that fall into an inclusive date range.
related_name
all()
range
through argument
19. Lookup type that returns results with a case-sensitive end sequence.
endswith
==
OneToOneField
iregex
20. 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
all()
intermediate models
filter chaining
Custom model methods
21. a QuerySet can be sliced - using Python's array-slicing syntax.
in_bulk(id_list)
dates(field - kind - order='ASC')
class attributes
slicing
22. The default for this is the name of the child class followed by '_set'.
relationship spanning
get_or_create(**kwargs)
reverse name
filter(**kwargs)
23. If this option is True - the field is allowed to be blank. Default is False.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
blank
get_or_create(**kwargs)
week_day
24. This method is more or less the opposite of defer(). You call it with the fields that should not be deferred when retrieving a model. If you have a model where almost all the fields need to be deferred - using this method to specify the complementary
all()
MultipleObjectsReturned
only(*fields)
exists()
25. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
iteration
exists()
dates(field - kind - order='ASC')
26. Returns the object matching the given lookup parameters
get(**kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
ManyToManyField
many-to-many relationship
27. 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.
Entry.objects.filter(pub_date__year=2005).delete()
db
class type
Many-to-many relationship through an intermediate model
28. This query finds all entries with an id greater than 4.
range
Entry.objects.filter(id__gt=4)
delete()
through argument
29. This query uses an F object to increment the pingback count for every entry in the blog.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
30. 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.
values_list(*fields)
|
count()
Model metadata
31. This field is added automatically - but this behavior can be overridden
id field
Manager
delete()
create(**kwargs)
32. 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
only(*fields)
F()
filter(**kwargs)
many-to-one relationship
33. Returns the most recent object in the table - by date - using the field_name provided as the date field.
count()
filter(**kwargs)
latest(field_name=None)
month
34. 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
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
gt
save()
Abstract base class
Manager
36. Lookup type that returns results greater than a given value.
relationship spanning
distinct()
gt
dates(field - kind - order='ASC')
37. 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.
exclude(**kwargs)
default
select_related()
when you add new apps to INSTALLED_APPS
38. 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.
intermediate models
pickling
pk
class type
39. Defines a one-to-one relationship. You use it just like any other Field type: by including it as a class attribute of your model.
evaluation
OneToOneField
dates(field - kind - order='ASC')
through argument
40. 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.
in_bulk(id_list)
aggregate(args - *kwargs)
filter
latest(field_name=None)
41. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
filter chaining
values(*fields)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
choices
42. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()
intermediate models
evaluation
filter
Entry.objects.filter(pub_date__year=2005).delete()
43. Returns a new QuerySet containing objects that match the given lookup parameters.
Many-to-many relationship to self
filter(**kwargs)
get_or_create(**kwargs)
clear() method
44. 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
45. This model method is used for updating a ManyToManyField.
add()
week_day
Model metadata
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
46. Lookup type that finds a case-sensitive regular expression match.
when you add new apps to INSTALLED_APPS
gte
regex
default
47. A convenience method for looking up an object with the given kwargs - creating one if necessary.
pk
distinct()
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
get_or_create(**kwargs)
48. This query finds all entries with an id in the list [1 - 3 - 4]
all()
|
lte
Entry.objects.filter(id__in=[1 - 3 - 4])
49. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
week_day
startswith
year
&
50. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
Custom model methods
related_name
delete()
aggregate(args - *kwargs)
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