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 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()
week_day
pickling
choices
2. These add custom "row-level" functionality to your objects. These act on a particular model instance.
contains
Custom model methods
exclude(**kwargs)
when you add new apps to INSTALLED_APPS
3. Lookup type for date/datetime fields that finds an exact day match.
endswith
Many-to-many relationship through an intermediate model
day
delete()
4. Lookup type that returns results less than a given value.
count()
lt
lte
iendswith
5. Lookup type that returns results with a case-insensitive end sequence.
search
in_bulk(id_list)
many-to-many relationship
iendswith
6. 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
evaluation
dates(field - kind - order='ASC')
intermediate models
exclude(**kwargs)
7. These are "anything that's not a field" - such as ordering options (ordering) - database table name (db_table) - or human-readable singular and plural names (verbose_name and verbose_name_plural)
count()
relationship spanning
Many-to-many relationship through an intermediate model
Model metadata
8. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()
relationship spanning
evaluation
Proxy model
endswith
9. 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
ForeignKey
delete()
F()
in
10. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
iendswith
evaluation
related_name
gt
11. Returns the object matching the given lookup parameters
get(**kwargs)
endswith
istartswith
year
12. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
add()
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Many-to-many relationship to self
one-to-one relationship
13. Lookup type that returns results that fall into an inclusive date range.
&
intermediate models
range
values_list(*fields)
14. 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
15. This gives your model metadata.
Meta class
QuerySet
null
when you add new apps to INSTALLED_APPS
16. This field is added automatically - but this behavior can be overridden
id field
pickling
Entry.objects.filter(id__in=[1 - 3 - 4])
exact
17. 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.
Multi-table inheritance
through argument
Entry.objects.filter(pub_date__range=(start_date - end_date))
week_day
18. 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.
ManyToManyField
only(*fields)
exclude(**kwargs)
unique
19. (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
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
slicing
20. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
iteration
exclude(**kwargs)
year
reverse()
21. Lookup type that returns results with a case-sensitive end sequence.
endswith
iteration
select_related()
Model metadata
22. 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
none()
only(*fields)
Proxy model
id field
23. If True - this field is the primary key for the model.
lt
primary_key
reverse()
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
24. If this option is True - the field is allowed to be blank. Default is False.
Manager methods
Entry.objects.filter(id__in=[1 - 3 - 4])
blank
iexact
25. 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.
intermediate models
regex
ForeignKey
startswith
26. Exception raised by get(**kwargs) if more than one item matches the query.
Entry.objects.filter(pub_date__range=(start_date - end_date))
evaluation
MultipleObjectsReturned
relationship spanning
27. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.
one-to-one relationship
Many-to-many relationship to self
many-to-one relationship
Abstract base class
28. 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.
many-to-one relationship
QuerySet
reverse name
iexact
29. 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.
gt
isnull
Many-to-many relationship to self
filter chaining
30. This is a criterion that narrow down a QuerySet based on given parameters.
latest(field_name=None)
pickling
filter
through argument
31. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
class attributes
isnull
==
get(**kwargs)
32. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
filter(**kwargs)
month
create(**kwargs)
many-to-many relationship
33. Exception raised by get(**kwargs) if no items match the query.
reverse()
annotate(args - *kwargs)
DoesNotExist
db
34. 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
using(alias)
gte
annotate(args - *kwargs)
save()
35. Returns the most recent object in the table - by date - using the field_name provided as the date field.
latest(field_name=None)
Manager
pickling
delete()
36. This model method is used for updating a ManyToManyField.
add()
Many-to-many relationship to self
evaluation
filter
37. Extra text to be displayed under the field on the object's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form.
aggregate(args - *kwargs)
filter(**kwargs)
Meta class
help_text
38. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
istartswith
Meta class
values_list(*fields)
39. This query deletes all Entry objects with a pub_date year of 2005.
Many-to-many relationship to self
filter(**kwargs)
Entry.objects.filter(pub_date__year=2005).delete()
class attributes
40. 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
41. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
many-to-many relationship
Custom model methods
pk
unique
42. Lookup type that returns results greater than a given value.
through argument
Custom model methods
gt
|
43. The default for this is the name of the child class followed by '_set'.
|
week_day
id field
reverse name
44. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
choices
get(**kwargs)
model
exists()
45. To activate your models
relationship spanning
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
gte
&
46. 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
47. Disjunction operator for Q objects.
|
one-to-one relationship
reverse()
iendswith
48. 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
reverse name
month
Abstract base class
Manager
49. Lookup type for date/datetime fields that finds a 'day of the week' match.
==
week_day
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
iendswith
50. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
all()
Manager
delete()
year