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. If you pickle a QuerySet - this will force all the results to be loaded into memory prior to pickling. When you unpickle a QuerySet - it contains the results at the moment it was pickled - rather than the results that are currently in the database.
pickling
through argument
&
filter chaining
2. If this option is True - the field is allowed to be blank. Default is False.
&
unique
Entry.objects.filter(id__gt=4)
blank
3. Conjuntion operator for Q objects.
Proxy model
gte
pk
&
4. To activate your models
search
DoesNotExist
gte
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
5. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
update(**kwargs)
Entry.objects.filter(pub_date__year=2005).delete()
filter(**kwargs)
iteration
6. 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.
get_absolute_url()
through argument
choices tuple
Entry.objects.filter(pub_date__year=2005).delete()
7. 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()
in_bulk(id_list)
default
evaluation
order_by(*fields)
8. Lookup type that returns results with a case-insensitive start sequence.
count()
OneToOneField
istartswith
iteration
9. These methods are intended to do "table-wide" things.
Entry.objects.filter(pub_date__range=(start_date - end_date))
pickling
Manager methods
select_related()
10. When to run syncdb
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
when you add new apps to INSTALLED_APPS
Q(question__istartswith='What')
Manager
11. 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.
filter(**kwargs)
month
update()
exact
12. 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
relationship spanning
istartswith
Proxy model
delete()
13. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.
choices tuple
update(**kwargs)
relationship spanning
when you add new apps to INSTALLED_APPS
14. Lookup type that tests for inclusion in a case-sensitive fashion.
class type
related_name
contains
dates(field - kind - order='ASC')
15. 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
iterator()
gte
default
aggregate(args - *kwargs)
16. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
endswith
values_list(*fields)
one-to-one relationship
reverse name
17. Exception raised by get(**kwargs) if more than one item matches the query.
iregex
MultipleObjectsReturned
lte
exact
18. Can be used to remove all many-to-many relationships for an instance
clear() method
update()
F()
iregex
19. Lookup type that returns results with a case-sensitive start sequence.
class type
get(**kwargs)
range
startswith
20. 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
21. This query deletes all Entry objects with a pub_date year of 2005.
month
Entry.objects.filter(pub_date__year=2005).delete()
Entry.objects.filter(id__gt=4)
choices
22. 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
Restrictions on field names
search
select_related()
&
23. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
exists()
istartswith
get_absolute_url()
year
24. 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
Field lookups
Entry.objects.filter(id__gt=4)
F()
25. Lookup type that returns results that fall into an inclusive date range.
range
endswith
exact
db
26. This model method is used for updating a ManyToManyField.
many-to-one relationship
year
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
add()
27. Returns a new QuerySet containing objects that match the given lookup parameters.
lt
filter(**kwargs)
search
MultipleObjectsReturned
28. Lookup type that returns results less than or equal to a given value.
lte
regex
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
dates(field - kind - order='ASC')
29. Lookup type for date/datetime fields that finds an exact day match.
day
latest(field_name=None)
iexact
defer(*fields)
30. 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.
exists()
&
OneToOneField
order_by(*fields)
31. Negation operator for Q objects.
pk
~
Restrictions on field names
Field lookups
32. If this option is True - Django will store empty values as NULL in the database. Default is False.
null
iregex
Q()
default
33. This represents a collection of objects from your database. It can have zero - one or many filters.
only(*fields)
QuerySet
latest(field_name=None)
all()
34. 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.
primary_key
save()
iteration
help_text
35. 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
defer(*fields)
aggregate(args - *kwargs)
values(*fields)
ordered
36. Lookup type that returns results greater than a given value.
reverse name
pickling
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
gt
37. 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
pickling
Restrictions on field names
slicing
none()
38. 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
one-to-one relationship
in_bulk(id_list)
&
relationship spanning
39. The default for this is the name of the child class followed by '_set'.
reverse name
clear() method
all()
Abstract base class
40. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
related_name
endswith
iregex
all()
41. Fields are specified by these
lte
delete()
class attributes
week_day
42. Lookup type that finds a case-insensitive regular expression match.
iregex
many-to-many relationship
DoesNotExist
annotate(args - *kwargs)
43. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
ordered
filter(**kwargs)
blank
44. Lookup type for date/datetime fields that finds a 'day of the week' match.
week_day
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
ManyToManyField
exclude(**kwargs)
45. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
day
intermediate models
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
values(*fields)
46. Lookup type that returns results less than a given value.
lt
evaluation
Multi-table inheritance
OneToOneField
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.
Model metadata
endswith
==
many-to-one relationship
48. Returns the object matching the given lookup parameters
only(*fields)
get(**kwargs)
OneToOneField
select_related()
49. This query finds all entries between a start date of start_date and an end date of end_date.
month
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
save()
Entry.objects.filter(pub_date__range=(start_date - end_date))
50. 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.
in_bulk(id_list)
Entry.objects.filter(id__gt=4)
endswith
exact