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
Entry.objects.filter(pub_date__range=(start_date - end_date))
clear() method
none()
regex
2. 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
filter(**kwargs)
defer(*fields)
update(**kwargs)
many-to-many relationship
3. 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
default
contains
through argument
iteration
4. The default for this is the name of the child class followed by '_set'.
MultipleObjectsReturned
reverse name
&
ManyToManyField
5. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
istartswith
month
endswith
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
6. Lookup type that returns results with a case-insensitive start sequence.
istartswith
id field
contains
reverse name
7. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
8. 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.
through argument
order_by(*fields)
iterator()
month
9. Returns the object matching the given lookup parameters
reverse()
iendswith
Q(question__istartswith='What')
get(**kwargs)
10. Lookup type that returns results with a case-sensitive end sequence.
update(**kwargs)
endswith
year
OneToOneField
11. Lookup type that yields a case-insensitive match.
class type
iexact
QuerySet
Q()
12. 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()
reverse name
range
evaluation
OneToOneField
13. This method returns tuples of values when iterated over. Each tuple contains the value from the respective field passed into the call to this method -- so the first item is the first field - etc.
latest(field_name=None)
delete()
|
values_list(*fields)
14. what the field _______ determines: (1) The database column type (e.g. INTEGER - VARCHAR); (2) The widget to use in Django's admin interface - if you care to use it (e.g. <input type="text"> - <select>); (3) The minimal validation requirements - used
Manager methods
Entry.objects.filter(id__in=[1 - 3 - 4])
class type
contains
15. This represents a collection of objects from your database. It can have zero - one or many filters.
filter chaining
QuerySet
iexact
month
16. Lookup type that returns results less than a given value.
lt
endswith
Field lookups
ManyToManyField
17. Fields are specified by these
select_related()
clear() method
Restrictions on field names
class attributes
18. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
Manager methods
DoesNotExist
model
Meta class
19. 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()
Model metadata
blank
iregex
20. 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
none()
through argument
21. 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.
model
choices tuple
ForeignKey
Many-to-many relationship through an intermediate model
22. 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
latest(field_name=None)
iteration
23. 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.
reverse name
pickling
MultipleObjectsReturned
using(alias)
24. 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
exact
dates(field - kind - order='ASC')
25. 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.
order_by(*fields)
Manager
Q()
model
26. Keyword shortcut for looking up an object by primary key.
choices tuple
in
pk
filter chaining
27. The database that will be used if this query is executed now
select_related()
model
db
Entry.objects.filter(id__in=[1 - 3 - 4])
28. 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)
contains
QuerySet
29. These methods are intended to do "table-wide" things.
get(**kwargs)
dates(field - kind - order='ASC')
using(alias)
Manager methods
30. 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.
default
isnull
ManyToManyField
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
31. This is a criterion that narrow down a QuerySet based on given parameters.
Entry.objects.filter(pub_date__year=2005).delete()
Meta class
filter
exists()
32. 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.
all()
update()
filter(**kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
33. This field is added automatically - but this behavior can be overridden
evaluation
iendswith
isnull
id field
34. Returns a dictionary of aggregate values (averages - sums - etc) calculated over the QuerySet. Each argument to this method specifies a value that will be included in the dictionary that is returned.
db
aggregate(args - *kwargs)
values_list(*fields)
Restrictions on field names
35. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
isnull
using(alias)
create(**kwargs)
QuerySet
36. This query finds all entries with an id in the list [1 - 3 - 4]
reverse()
id field
MultipleObjectsReturned
Entry.objects.filter(id__in=[1 - 3 - 4])
37. If this option is True - Django will store empty values as NULL in the database. Default is False.
null
class attributes
unique
clear() method
38. 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
F()
delete()
DoesNotExist
iexact
39. 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
40. Exception raised by get(**kwargs) if more than one item matches the query.
MultipleObjectsReturned
week_day
Entry.objects.filter(id__in=[1 - 3 - 4])
save()
41. 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
db
isnull
select_related()
get(**kwargs)
42. Lookup type that returns results less than or equal to a given value.
lte
DoesNotExist
distinct()
help_text
43. 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.
filter chaining
delete()
model
intermediate models
44. 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
lte
db
45. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
iteration
exclude(**kwargs)
startswith
pickling
46. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
__unicode__()
Entry.objects.filter(pub_date__range=(start_date - end_date))
week_day
year
47. Conjuntion operator for Q objects.
istartswith
defer(*fields)
&
aggregate(args - *kwargs)
48. (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.
model
Restrictions on field names
Many-to-many relationship through an intermediate model
none()
49. Lookup type for date/datetime fields that finds an exact day match.
help_text
day
Entry.objects.filter(id__gt=4)
latest(field_name=None)
50. 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.
regex
help_text
delete()
pickling