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. 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.
Proxy model
in_bulk(id_list)
exclude(**kwargs)
Many-to-many relationship to self
2. 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.
ManyToManyField
Many-to-many relationship through an intermediate model
get(**kwargs)
Multi-table inheritance
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.
many-to-one relationship
Proxy model
id field
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
4. Lookup type that returns results less than a given value.
lt
many-to-one relationship
filter chaining
exclude(**kwargs)
5. A convenience method for looking up an object with the given kwargs - creating one if necessary.
count()
get_or_create(**kwargs)
get(**kwargs)
~
6. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
iteration
update()
Proxy model
defer(*fields)
7. Lookup type that yields a case-insensitive match.
iexact
contains
update()
Custom model methods
8. Returns True if the QuerySet contains any results - and False if not. This tries to perform the query in the simplest and fastest way possible - but it does execute nearly the same query. This means that calling this method on a queryset is faster th
intermediate models
exists()
primary_key
db
9. Lookup type for date/datetime fields that finds a 'day of the week' match.
one-to-one relationship
week_day
values_list(*fields)
filter(**kwargs)
10. 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.
Custom model methods
OneToOneField
gte
reverse()
11. Lookup type that returns results that fall into an inclusive date range.
help_text
range
QuerySet
only(*fields)
12. Lookup type that finds a case-sensitive regular expression match.
Many-to-many relationship to self
regex
values_list(*fields)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
13. Lookup type that returns results in a given list.
ForeignKey
in
Custom model methods
all()
14. Fields are specified by these
choices
exists()
class attributes
~
15. Manager method used to retrieve every object in a model.
relationship spanning
endswith
all()
unique
16. Lookup type that returns results with a case-sensitive end sequence.
Manager
when you add new apps to INSTALLED_APPS
endswith
values_list(*fields)
17. 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
relationship spanning
Entry.objects.filter(id__in=[1 - 3 - 4])
&
Multi-table inheritance
18. This query deletes all Entry objects with a pub_date year of 2005.
~
MultipleObjectsReturned
save()
Entry.objects.filter(pub_date__year=2005).delete()
19. A Python "magic method" that returns a unicode "representation" of any object.
dates(field - kind - order='ASC')
Entry.objects.filter(pub_date__year=2005).delete()
__unicode__()
day
20. 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.
==
dates(field - kind - order='ASC')
class attributes
reverse()
21. This query finds all entries between a start date of start_date and an end date of end_date.
day
OneToOneField
all()
Entry.objects.filter(pub_date__range=(start_date - end_date))
22. Can be used to remove all many-to-many relationships for an instance
clear() method
filter chaining
reverse name
blank
23. 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
24. 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
25. If True - this field is the primary key for the model.
primary_key
Entry.objects.filter(id__gt=4)
dates(field - kind - order='ASC')
related_name
26. This field is added automatically - but this behavior can be overridden
id field
primary_key
MultipleObjectsReturned
search
27. Negation operator for Q objects.
~
Manager methods
exact
only(*fields)
28. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
pk
isnull
get_absolute_url()
ordered
29. This model method is used for updating a ManyToManyField.
add()
QuerySet
gt
null
30. This gives your model metadata.
filter(**kwargs)
gt
ForeignKey
Meta class
31. 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.
ForeignKey
annotate(args - *kwargs)
delete()
startswith
32. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
help_text
id field
count()
QuerySet
33. Keyword shortcut for looking up an object by primary key.
iterator()
values_list(*fields)
pk
in_bulk(id_list)
34. 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.
istartswith
default
Restrictions on field names
Manager methods
35. When to run syncdb
latest(field_name=None)
when you add new apps to INSTALLED_APPS
ForeignKey
db
36. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
Abstract base class
values(*fields)
year
blank
37. The default for this is the name of the child class followed by '_set'.
get(**kwargs)
reverse name
lt
update(**kwargs)
38. Conjuntion operator for Q objects.
Entry.objects.filter(id__gt=4)
|
&
defer(*fields)
39. Lookup type that finds a case-insensitive regular expression match.
dates(field - kind - order='ASC')
iregex
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
class type
40. 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
QuerySet
|
MultipleObjectsReturned
annotate(args - *kwargs)
41. 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.
Many-to-many relationship to self
Many-to-many relationship through an intermediate model
Multi-table inheritance
add()
42. 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
model
week_day
Proxy model
reverse name
43. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Custom model methods
all()
pickling
save()
44. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
search
Many-to-many relationship to self
Entry.objects.filter(pub_date__range=(start_date - end_date))
exclude(**kwargs)
45. 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)
latest(field_name=None)
class type
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
46. A convenience method for constructing an object and saving it all in one step.
class type
gte
filter(**kwargs)
create(**kwargs)
47. Returns a new QuerySet containing objects that match the given lookup parameters.
delete()
exclude(**kwargs)
pk
filter(**kwargs)
48. This query finds all entries with an id in the list [1 - 3 - 4]
related_name
Abstract base class
Entry.objects.filter(id__in=[1 - 3 - 4])
get(**kwargs)
49. To activate your models
|
select_related()
endswith
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
50. 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
order_by(*fields)
iterator()
pickling
relationship spanning
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