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. This model method is used for updating a ManyToManyField.
add()
dates(field - kind - order='ASC')
Entry.objects.filter(id__in=[1 - 3 - 4])
iregex
2. A convenience method for constructing an object and saving it all in one step.
week_day
contains
add()
create(**kwargs)
3. Keyword shortcut for looking up an object by primary key.
pk
gte
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
lt
4. This represents a collection of objects from your database. It can have zero - one or many filters.
exclude(**kwargs)
gt
QuerySet
add()
5. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
values(*fields)
istartswith
iterator()
6. 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.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
aggregate(args - *kwargs)
regex
order_by(*fields)
7. 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.
latest(field_name=None)
update()
Entry.objects.filter(pub_date__range=(start_date - end_date))
F()
8. Lookup type that finds a case-insensitive regular expression match.
values(*fields)
iregex
Custom model methods
filter
9. This query finds all entries between a start date of start_date and an end date of end_date.
Entry.objects.filter(pub_date__range=(start_date - end_date))
Multi-table inheritance
in_bulk(id_list)
iexact
10. 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.
default
class type
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
get_absolute_url()
11. 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
filter chaining
add()
only(*fields)
distinct()
12. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.
pk
search
iteration
evaluation
13. Fields are specified by these
add()
class attributes
Model metadata
week_day
14. Lookup type that returns results less than or equal to a given value.
isnull
get_or_create(**kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
lte
15. 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.
DoesNotExist
regex
==
get(**kwargs)
16. This is a criterion that narrow down a QuerySet based on given parameters.
through argument
dates(field - kind - order='ASC')
pk
filter
17. 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.
istartswith
Q()
class type
count()
18. 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.
QuerySet
Many-to-many relationship through an intermediate model
filter(**kwargs)
id field
19. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
one-to-one relationship
==
exact
~
20. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.
choices
|
when you add new apps to INSTALLED_APPS
ManyToManyField
21. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
one-to-one relationship
filter chaining
many-to-one relationship
22. 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
Q(question__istartswith='What')
&
__unicode__()
annotate(args - *kwargs)
23. 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
select_related()
get(**kwargs)
id field
ForeignKey
24. When to run syncdb
when you add new apps to INSTALLED_APPS
==
count()
Manager methods
25. If True - this field is the primary key for the model.
year
endswith
select_related()
primary_key
26. Defines a many-to-many relationship. You use it just like any other Field type: by including it as a class attribute of your model.
get_absolute_url()
related_name
Many-to-many relationship to self
ManyToManyField
27. Manager method used to retrieve every object in a model.
relationship spanning
filter(**kwargs)
|
all()
28. Lookup type that returns results with a case-insensitive start sequence.
OneToOneField
istartswith
unique
==
29. Lookup type for date/datetime fields that finds a 'day of the week' match.
iexact
week_day
default
using(alias)
30. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
default
ForeignKey
Entry.objects.filter(pub_date__range=(start_date - end_date))
31. 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.
ForeignKey
select_related()
QuerySet
Entry.objects.filter(id__gt=4)
32. Lookup type that returns results greater than or equal to a given value.
evaluation
iregex
Proxy model
gte
33. 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()
class attributes
when you add new apps to INSTALLED_APPS
many-to-one relationship
34. 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.
iexact
in_bulk(id_list)
get_absolute_url()
DoesNotExist
35. Returns a new QuerySet containing objects that match the given lookup parameters.
F()
~
iendswith
filter(**kwargs)
36. Lookup type that finds a case-sensitive regular expression match.
regex
__unicode__()
add()
endswith
37. 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
DoesNotExist
defer(*fields)
default
values(*fields)
38. A Python "magic method" that returns a unicode "representation" of any object.
ordered
Abstract base class
filter(**kwargs)
__unicode__()
39. If this option is True - the field is allowed to be blank. Default is False.
blank
class attributes
update()
get_or_create(**kwargs)
40. 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
41. 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
filter
F()
intermediate models
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
42. 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
Abstract base class
slicing
model
primary_key
43. 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.
day
search
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
filter chaining
44. These methods are intended to do "table-wide" things.
Manager methods
id field
lte
get_or_create(**kwargs)
45. Lookup type that returns results less than a given value.
filter(**kwargs)
update()
lt
in_bulk(id_list)
46. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
pickling
week_day
Field lookups
Manager
47. 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
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
get_absolute_url()
startswith
all()
48. The database that will be used if this query is executed now
unique
class attributes
db
dates(field - kind - order='ASC')
49. a QuerySet can be sliced - using Python's array-slicing syntax.
help_text
slicing
many-to-many relationship
lte
50. Exception raised by get(**kwargs) if no items match the query.
search
DoesNotExist
db
iterator()
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