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 is a criterion that narrow down a QuerySet based on given parameters.
filter
exact
iteration
latest(field_name=None)
2. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
create(**kwargs)
OneToOneField
Meta class
3. 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
when you add new apps to INSTALLED_APPS
__unicode__()
startswith
4. If this option is True - the field is allowed to be blank. Default is False.
Abstract base class
Proxy model
~
blank
5. 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.
order_by(*fields)
Custom model methods
ManyToManyField
relationship spanning
6. 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
Entry.objects.filter(pub_date__range=(start_date - end_date))
lt
iendswith
7. 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
8. 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.
id field
help_text
filter chaining
null
9. 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.
week_day
in
values(*fields)
many-to-one relationship
10. Lookup type that returns results that fall into an inclusive date range.
range
choices tuple
exclude(**kwargs)
through argument
11. 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
Many-to-many relationship to self
select_related()
Proxy model
year
12. 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.
reverse()
id field
MultipleObjectsReturned
OneToOneField
13. This model method is used for updating a ManyToManyField.
endswith
Entry.objects.filter(id__in=[1 - 3 - 4])
add()
iendswith
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. If True - this field is the primary key for the model.
Entry.objects.filter(pub_date__year=2005).delete()
Many-to-many relationship through an intermediate model
primary_key
range
16. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
ManyToManyField
when you add new apps to INSTALLED_APPS
iteration
values(*fields)
17. The database that will be used if this query is executed now
db
|
~
order_by(*fields)
18. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
dates(field - kind - order='ASC')
ManyToManyField
choices tuple
19. 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
iendswith
one-to-one relationship
annotate(args - *kwargs)
20. Fields are specified by these
get(**kwargs)
one-to-one relationship
many-to-one relationship
class attributes
21. Manager method used to retrieve every object in a model.
db
help_text
get(**kwargs)
all()
22. 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.
lte
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
Many-to-many relationship to self
annotate(args - *kwargs)
23. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
lte
related_name
order_by(*fields)
iregex
24. Lookup type that returns results greater than or equal to a given value.
gte
F()
Many-to-many relationship to self
OneToOneField
25. Lookup type that yields a case-insensitive match.
iexact
|
month
count()
26. 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)
delete()
slicing
year
27. 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
select_related()
related_name
slicing
28. Lookup type that returns results greater than a given value.
gt
QuerySet
~
db
29. Negation operator for Q objects.
range
~
class type
many-to-one relationship
30. 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.
range
ordered
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
exact
31. This method immediately deletes the object and has no return value.
delete()
Q()
intermediate models
iteration
32. 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
get(**kwargs)
select_related()
one-to-one relationship
exact
33. Lookup type that finds a case-sensitive regular expression match.
blank
regex
Abstract base class
get(**kwargs)
34. Lookup type that returns results in a given list.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
in
Restrictions on field names
exclude(**kwargs)
35. 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()
Manager methods
day
Meta class
36. 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
delete()
count()
all()
iregex
37. 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.
filter chaining
ManyToManyField
exists()
search
38. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
Field lookups
intermediate models
class type
id field
39. Keyword shortcut for looking up an object by primary key.
get_absolute_url()
pk
Q(question__istartswith='What')
lte
40. Lookup type for date/datetime fields that finds an exact day match.
Entry.objects.filter(pub_date__year=2005).delete()
F()
day
values(*fields)
41. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
model
latest(field_name=None)
create(**kwargs)
class type
42. Lookup type that tests for inclusion in a case-sensitive fashion.
Model metadata
contains
exclude(**kwargs)
class type
43. 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.
none()
choices
get(**kwargs)
exists()
44. Returns the object matching the given lookup parameters
get(**kwargs)
get_absolute_url()
Entry.objects.filter(pub_date__year=2005).delete()
F()
45. When to run syncdb
when you add new apps to INSTALLED_APPS
add()
id field
&
46. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
Proxy model
slicing
primary_key
count()
47. 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
48. 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.
values(*fields)
in
using(alias)
istartswith
49. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
ordered
one-to-one relationship
choices
get_absolute_url()
50. 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)
delete()
OneToOneField