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. Returns a new QuerySet containing objects that match the given lookup parameters.
choices
gte
filter(**kwargs)
Meta class
2. 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.
update(**kwargs)
only(*fields)
Manager methods
reverse()
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.
range
one-to-one relationship
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
filter chaining
4. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
ordered
primary_key
related_name
ForeignKey
5. 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
6. 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
7. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
istartswith
exclude(**kwargs)
Meta class
isnull
8. Fields are specified by these
gte
filter chaining
class attributes
ordered
9. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
lt
search
model
Field lookups
10. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
distinct()
default
month
F()
11. Lookup type that returns results in a given list.
filter(**kwargs)
in
class attributes
isnull
12. 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.
month
Field lookups
delete()
reverse()
13. This tells Django how to calculate the URL for an object. Django uses this in its admin interface - and any time it needs to figure out a URL for an object.
defer(*fields)
get(**kwargs)
Restrictions on field names
get_absolute_url()
14. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
using(alias)
iteration
ordered
help_text
15. This model method is used for updating a ManyToManyField.
add()
choices tuple
endswith
through argument
16. When to run syncdb
Restrictions on field names
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
related_name
when you add new apps to INSTALLED_APPS
17. Lookup type that returns results with a case-insensitive start sequence.
Q(question__istartswith='What')
Abstract base class
istartswith
iendswith
18. 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.
get(**kwargs)
~
iendswith
iteration
19. A Python "magic method" that returns a unicode "representation" of any object.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
intermediate models
|
__unicode__()
20. Lookup type that tests for inclusion in a case-sensitive fashion.
get_absolute_url()
F()
update(**kwargs)
contains
21. Lookup type that returns results with a case-sensitive start sequence.
values(*fields)
Proxy model
iexact
startswith
22. 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
Proxy model
all()
through argument
lt
23. Lookup type that yields a case-insensitive match.
iexact
latest(field_name=None)
Custom model methods
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
24. 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))
many-to-one relationship
Meta class
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
25. 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.
update(**kwargs)
~
using(alias)
Multi-table inheritance
26. Lookup type that returns results greater than a given value.
in
Entry.objects.filter(pub_date__year=2005).delete()
gt
|
27. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
MultipleObjectsReturned
create(**kwargs)
evaluation
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
none()
choices tuple
Proxy model
delete()
29. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
Entry.objects.filter(id__in=[1 - 3 - 4])
==
ordered
many-to-many relationship
30. The database that will be used if this query is executed now
db
Proxy model
get(**kwargs)
ordered
31. This is a criterion that narrow down a QuerySet based on given parameters.
annotate(args - *kwargs)
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
filter
intermediate models
32. A convenience method for constructing an object and saving it all in one step.
Proxy model
many-to-many relationship
create(**kwargs)
lt
33. 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
34. 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
through argument
Entry.objects.filter(id__in=[1 - 3 - 4])
reverse name
iterator()
35. Disjunction operator for Q objects.
|
none()
iregex
values_list(*fields)
36. 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.
get(**kwargs)
ForeignKey
default
annotate(args - *kwargs)
37. (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.
Restrictions on field names
default
Entry.objects.filter(pub_date__year=2005).delete()
endswith
38. 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
all()
order_by(*fields)
get_or_create(**kwargs)
39. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
only(*fields)
get(**kwargs)
evaluation
40. Keyword shortcut for looking up an object by primary key.
Abstract base class
isnull
exclude(**kwargs)
pk
41. If True - this field is the primary key for the model.
Model metadata
primary_key
exact
DoesNotExist
42. Lookup type that returns results with a case-sensitive end sequence.
none()
Many-to-many relationship to self
endswith
many-to-one relationship
43. This query deletes all Entry objects with a pub_date year of 2005.
pk
year
Entry.objects.filter(pub_date__year=2005).delete()
Manager
44. 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
annotate(args - *kwargs)
slicing
get(**kwargs)
exact
45. Lookup type that returns results less than or equal to a given value.
Restrictions on field names
lte
&
db
46. 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
regex
Custom model methods
id field
update(**kwargs)
47. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
Custom model methods
iteration
exclude(**kwargs)
Entry.objects.filter(id__gt=4)
48. Exception raised by get(**kwargs) if no items match the query.
ForeignKey
DoesNotExist
in_bulk(id_list)
help_text
49. 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
50. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
id field
through argument
Manager methods
distinct()
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