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 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.
exact
Entry.objects.filter(id__in=[1 - 3 - 4])
Abstract base class
choices tuple
2. This query finds all entries between a start date of start_date and an end date of end_date.
Manager
Entry.objects.filter(pub_date__range=(start_date - end_date))
MultipleObjectsReturned
in
3. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.
delete()
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
filter chaining
values(*fields)
4. 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
5. Lookup type that finds a case-sensitive regular expression match.
create(**kwargs)
none()
values_list(*fields)
regex
6. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
using(alias)
~
==
gte
7. Returns the object matching the given lookup parameters
get(**kwargs)
iexact
pickling
QuerySet
8. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
only(*fields)
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
one-to-one relationship
OneToOneField
9. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
10. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
startswith
when you add new apps to INSTALLED_APPS
iexact
11. 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
12. This query finds all entries with an id greater than 4.
add()
Proxy model
Entry.objects.filter(id__gt=4)
Model metadata
13. 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.
Field lookups
default
Manager
Q()
14. Lookup type that finds a case-insensitive regular expression match.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
iregex
none()
defer(*fields)
15. Lookup type that returns results that fall into an inclusive date range.
Meta class
Entry.objects.filter(id__gt=4)
range
Manager
16. This method immediately deletes the object and has no return value.
order_by(*fields)
unique
delete()
get(**kwargs)
17. 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)
exists()
help_text
defer(*fields)
18. The database that will be used if this query is executed now
values(*fields)
order_by(*fields)
delete()
db
19. 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
id field
Proxy model
Multi-table inheritance
isnull
20. This query finds all entries with an id in the list [1 - 3 - 4]
__unicode__()
Entry.objects.filter(id__in=[1 - 3 - 4])
distinct()
select_related()
21. 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.
endswith
Entry.objects.filter(pub_date__year=2005).delete()
get(**kwargs)
using(alias)
22. Lookup type that returns results with a case-insensitive end sequence.
create(**kwargs)
unique
iendswith
lt
23. Lookup type that returns results less than or equal to a given value.
lte
filter
istartswith
gt
24. Lookup type that tests for inclusion in a case-sensitive fashion.
order_by(*fields)
one-to-one relationship
contains
distinct()
25. These add custom "row-level" functionality to your objects. These act on a particular model instance.
count()
startswith
Custom model methods
QuerySet
26. 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
intermediate models
delete()
regex
pk
27. Exception raised by get(**kwargs) if more than one item matches the query.
aggregate(args - *kwargs)
MultipleObjectsReturned
Manager
add()
28. 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.
Q()
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
evaluation
choices tuple
29. Returns the most recent object in the table - by date - using the field_name provided as the date field.
week_day
latest(field_name=None)
update(**kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
30. 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
lte
isnull
get_or_create(**kwargs)
through argument
31. (1) These cannot be Python reserved words - because that would result in a Python syntax error. (2) These cannot contain more than one underscore in a row - due to the way Django's query lookup syntax works.
in_bulk(id_list)
delete()
Restrictions on field names
range
32. 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
ManyToManyField
day
select_related()
endswith
33. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
distinct()
ManyToManyField
search
blank
34. 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.
Multi-table inheritance
delete()
Q(question__istartswith='What')
all()
35. 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.
OneToOneField
~
week_day
lt
36. To activate your models
save()
Manager
isnull
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
37. what the field _______ determines: (1) The database column type (e.g. INTEGER - VARCHAR); (2) The widget to use in Django's admin interface - if you care to use it (e.g. <input type="text"> - <select>); (3) The minimal validation requirements - used
filter(**kwargs)
Q()
class type
QuerySet
38. 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.
filter(**kwargs)
lt
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
Multi-table inheritance
39. Fields are specified by these
class attributes
Entry.objects.filter(pub_date__year=2005).delete()
pk
Model metadata
40. The default for this is the name of the child class followed by '_set'.
iteration
Meta class
only(*fields)
reverse name
41. Lookup type that returns results with a case-sensitive end sequence.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
endswith
save()
update()
42. Can be used to remove all many-to-many relationships for an instance
clear() method
iregex
unique
id field
43. Lookup type that returns results greater than a given value.
contains
create(**kwargs)
Manager methods
gt
44. This field is added automatically - but this behavior can be overridden
Proxy model
id field
default
get_or_create(**kwargs)
45. 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
46. 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
lt
all()
one-to-one relationship
lte
47. Conjuntion operator for Q objects.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
&
search
Q()
48. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
all()
Manager
month
get(**kwargs)
49. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
one-to-one relationship
MultipleObjectsReturned
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
50. Lookup type that returns results greater than or equal to a given value.
Manager
Manager methods
gte
Many-to-many relationship to self
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