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. The default for this is the name of the child class followed by '_set'.
update(**kwargs)
range
dates(field - kind - order='ASC')
reverse name
2. 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.
order_by(*fields)
using(alias)
Many-to-many relationship to self
regex
3. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
search
Manager methods
primary_key
4. Lookup type for date/datetime fields that finds a 'day of the week' match.
DoesNotExist
week_day
F()
endswith
5. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
annotate(args - *kwargs)
reverse()
exact
6. 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.
dates(field - kind - order='ASC')
Multi-table inheritance
Q(question__istartswith='What')
OneToOneField
7. Lookup type that yields a case-insensitive match.
iexact
Many-to-many relationship through an intermediate model
get_absolute_url()
gte
8. 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
save()
Many-to-many relationship to self
delete()
9. This method immediately deletes the object and has no return value.
choices tuple
reverse()
delete()
contains
10. Lookup type that returns results with a case-sensitive start sequence.
month
filter(**kwargs)
filter(**kwargs)
startswith
11. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
search
iregex
regex
12. Manager method used to retrieve every object in a model.
delete()
many-to-many relationship
iterator()
all()
13. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
exact
none()
year
Many-to-many relationship through an intermediate model
14. 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
null
defer(*fields)
ForeignKey
get_absolute_url()
15. 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.
intermediate models
default
relationship spanning
all()
16. 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
17. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
OneToOneField
month
only(*fields)
18. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
intermediate models
id field
contains
one-to-one relationship
19. If True - the table does not permit duplicate values for this field.
unique
relationship spanning
ForeignKey
reverse()
20. 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
21. 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
class type
reverse()
Entry.objects.filter(pub_date__range=(start_date - end_date))
ordered
22. Lookup type that finds a case-insensitive regular expression match.
get_or_create(**kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
pickling
iregex
23. Lookup type that finds a case-sensitive regular expression match.
search
regex
month
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
24. Lookup type that returns results with a case-sensitive end sequence.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
endswith
update()
many-to-one relationship
25. This gives your model metadata.
Multi-table inheritance
Meta class
month
iexact
26. 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.
model
order_by(*fields)
Entry.objects.filter(id__gt=4)
help_text
27. These add custom "row-level" functionality to your objects. These act on a particular model instance.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Entry.objects.filter(pub_date__range=(start_date - end_date))
Custom model methods
save()
28. 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
default
|
null
none()
29. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
QuerySet
ordered
many-to-many relationship
Q()
30. 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.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
iexact
day
delete()
31. 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
reverse name
==
select_related()
Proxy model
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
F()
iterator()
startswith
day
33. Conjuntion operator for Q objects.
when you add new apps to INSTALLED_APPS
&
pk
iteration
34. This is a criterion that narrow down a QuerySet based on given parameters.
count()
through argument
Manager methods
filter
35. Exception raised by get(**kwargs) if no items match the query.
Manager methods
db
blank
DoesNotExist
36. Use this method to reverse the order in which a queryset's elements are returned. Calling this method a second time restores the ordering back to the normal direction.
reverse()
filter(**kwargs)
one-to-one relationship
==
37. This field is added automatically - but this behavior can be overridden
istartswith
id field
gte
many-to-many relationship
38. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
&
choices
month
add()
39. Keyword shortcut for looking up an object by primary key.
add()
Restrictions on field names
id field
pk
40. 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
41. 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.
~
Entry.objects.filter(pub_date__range=(start_date - end_date))
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
only(*fields)
42. Lookup type that returns results in a given list.
get_absolute_url()
ManyToManyField
only(*fields)
in
43. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo
&
clear() method
month
relationship spanning
44. 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.
lte
db
year
ForeignKey
45. To activate your models
OneToOneField
reverse name
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Entry.objects.filter(pub_date__range=(start_date - end_date))
46. Fields are specified by these
filter(**kwargs)
id field
class attributes
Restrictions on field names
47. Defined by django.db.models.ForeignKey. You use it just like any other Field type: by including it as a class attribute of your model.
dates(field - kind - order='ASC')
many-to-one relationship
when you add new apps to INSTALLED_APPS
gt
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.
exact
count()
one-to-one relationship
isnull
49. Lookup type for date/datetime fields that finds an exact day match.
slicing
range
day
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
50. 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.
gte
search
filter chaining
unique
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