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. 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
2. Negation operator for Q objects.
~
lt
through argument
Model metadata
3. Lookup type that finds a case-sensitive regular expression match.
get(**kwargs)
regex
Custom model methods
istartswith
4. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
Entry.objects.filter(id__in=[1 - 3 - 4])
pk
model
5. Lookup type that returns results that fall into an inclusive date range.
many-to-many relationship
exclude(**kwargs)
evaluation
range
6. (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
range
Meta class
search
7. Lookup type that returns results with a case-insensitive start sequence.
model
year
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
istartswith
8. 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
search
intermediate models
Abstract base class
|
9. Lookup type that returns results with a case-sensitive start sequence.
startswith
Manager methods
Entry.objects.filter(id__gt=4)
day
10. This method immediately deletes the object and has no return value.
pickling
delete()
OneToOneField
Q()
11. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
gte
values_list(*fields)
ForeignKey
year
12. 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
__unicode__()
through argument
Field lookups
all()
13. Returns the object matching the given lookup parameters
values(*fields)
get(**kwargs)
regex
all()
14. If this option is True - the field is allowed to be blank. Default is False.
save()
lte
blank
get(**kwargs)
15. 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.
get(**kwargs)
latest(field_name=None)
db
help_text
16. 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
all()
choices tuple
iexact
__unicode__()
17. 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.
filter chaining
Field lookups
OneToOneField
aggregate(args - *kwargs)
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)
id field
Custom model methods
reverse()
19. Lookup type that returns results less than or equal to a given value.
lte
range
select_related()
reverse name
20. 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.
istartswith
exact
iendswith
many-to-many relationship
21. Lookup type that yields a case-insensitive match.
one-to-one relationship
distinct()
iregex
iexact
22. These methods are intended to do "table-wide" things.
get(**kwargs)
id field
Manager methods
gte
23. 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
in
annotate(args - *kwargs)
defer(*fields)
exact
24. 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.
using(alias)
db
filter chaining
none()
25. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
contains
latest(field_name=None)
values(*fields)
Model metadata
26. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
one-to-one relationship
exact
isnull
update(**kwargs)
27. A Python "magic method" that returns a unicode "representation" of any object.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
|
__unicode__()
filter
28. 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.
related_name
blank
default
order_by(*fields)
29. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
Abstract base class
iteration
MultipleObjectsReturned
get(**kwargs)
30. Returns a new QuerySet containing objects that match the given lookup parameters.
iendswith
reverse name
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
filter(**kwargs)
31. 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
order_by(*fields)
get_absolute_url()
through argument
class type
32. 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.
id field
choices tuple
in_bulk(id_list)
Manager methods
33. Exception raised by get(**kwargs) if more than one item matches the query.
Multi-table inheritance
choices
iexact
MultipleObjectsReturned
34. If True - the table does not permit duplicate values for this field.
unique
reverse name
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Proxy model
35. 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
relationship spanning
pk
update(**kwargs)
unique
36. 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.
pickling
defer(*fields)
aggregate(args - *kwargs)
choices
37. 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
38. 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.
Restrictions on field names
when you add new apps to INSTALLED_APPS
ForeignKey
get(**kwargs)
39. The database that will be used if this query is executed now
db
class attributes
ManyToManyField
~
40. Lookup type that finds a case-insensitive regular expression match.
count()
==
iregex
delete()
41. a QuerySet can be sliced - using Python's array-slicing syntax.
Q()
slicing
Entry.objects.filter(pub_date__range=(start_date - end_date))
Model metadata
42. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
relationship spanning
gt
update()
43. A convenience method for looking up an object with the given kwargs - creating one if necessary.
Manager methods
endswith
get_or_create(**kwargs)
all()
44. This is a criterion that narrow down a QuerySet based on given parameters.
~
F()
values_list(*fields)
filter
45. 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.
Entry.objects.filter(pub_date__year=2005).delete()
using(alias)
update()
search
46. 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.
regex
Entry.objects.filter(pub_date__year=2005).delete()
evaluation
update()
47. 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
day
iendswith
endswith
48. When to run syncdb
reverse()
when you add new apps to INSTALLED_APPS
intermediate models
search
49. 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
50. 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
many-to-one relationship
Custom model methods
F()
Meta class