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. Lookup type that returns results with a case-sensitive end sequence.
Abstract base class
endswith
create(**kwargs)
class type
2. 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.
one-to-one relationship
default
slicing
Multi-table inheritance
3. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
Q()
&
model
|
4. When to run syncdb
when you add new apps to INSTALLED_APPS
==
month
__unicode__()
5. Exception raised by get(**kwargs) if more than one item matches the query.
MultipleObjectsReturned
range
__unicode__()
gte
6. A convenience method for looking up an object with the given kwargs - creating one if necessary.
model
get_or_create(**kwargs)
aggregate(args - *kwargs)
Many-to-many relationship through an intermediate model
7. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
none()
range
DoesNotExist
ordered
8. Lookup type that returns results in a given list.
Abstract base class
in
Model metadata
day
9. 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.
choices tuple
Q()
ManyToManyField
help_text
10. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Custom model methods
Multi-table inheritance
endswith
latest(field_name=None)
11. 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
12. This query finds all entries with an id greater than 4.
delete()
update(**kwargs)
range
Entry.objects.filter(id__gt=4)
13. 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.
help_text
aggregate(args - *kwargs)
annotate(args - *kwargs)
choices tuple
14. 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
filter
year
annotate(args - *kwargs)
many-to-one relationship
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
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
iterator()
many-to-many relationship
gte
16. If this option is True - Django will store empty values as NULL in the database. Default is False.
null
year
when you add new apps to INSTALLED_APPS
get(**kwargs)
17. Disjunction operator for Q objects.
select_related()
|
using(alias)
exact
18. 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
Entry.objects.filter(id__in=[1 - 3 - 4])
class type
update(**kwargs)
order_by(*fields)
19. a QuerySet can be sliced - using Python's array-slicing syntax.
when you add new apps to INSTALLED_APPS
QuerySet
slicing
Model metadata
20. If this option is True - the field is allowed to be blank. Default is False.
blank
OneToOneField
day
order_by(*fields)
21. 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__year=2007).update(headline='Everything is the same')
get_absolute_url()
none()
defer(*fields)
22. Lookup type that returns results greater than or equal to a given value.
~
null
pk
gte
23. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
lte
one-to-one relationship
count()
get(**kwargs)
24. Use this method to reverse the order in which a queryset's elements are returned. Calling this method a second time restores the ordering back to the normal direction.
reverse()
|
create(**kwargs)
iexact
25. If True - the table does not permit duplicate values for this field.
year
unique
~
count()
26. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
relationship spanning
get(**kwargs)
ordered
==
27. (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
none()
Many-to-many relationship to self
reverse name
28. 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
choices
get(**kwargs)
range
select_related()
29. Lookup type that tests for inclusion in a case-sensitive fashion.
Many-to-many relationship to self
iteration
Proxy model
contains
30. 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.
aggregate(args - *kwargs)
range
reverse()
many-to-one relationship
31. Lookup type that finds a case-insensitive regular expression match.
exact
Manager methods
in_bulk(id_list)
iregex
32. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
Many-to-many relationship through an intermediate model
relationship spanning
distinct()
33. If True - this field is the primary key for the model.
istartswith
intermediate models
null
primary_key
34. Conjuntion operator for Q objects.
iendswith
&
OneToOneField
__unicode__()
35. Returns the most recent object in the table - by date - using the field_name provided as the date field.
exists()
latest(field_name=None)
evaluation
istartswith
36. 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()
lt
select_related()
exclude(**kwargs)
37. Lookup type that returns results with a case-insensitive end sequence.
primary_key
iendswith
in
MultipleObjectsReturned
38. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
iteration
Q(question__istartswith='What')
many-to-many relationship
reverse name
39. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
delete()
reverse name
count()
Entry.objects.filter(pub_date__year=2005).delete()
40. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__gt=4)
lte
related_name
Entry.objects.filter(id__in=[1 - 3 - 4])
41. 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
&
pk
endswith
42. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
null
year
through argument
class type
43. This model method saves a model instance to the database. This method has no return value.
ordered
relationship spanning
save()
default
44. 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.
one-to-one relationship
filter
exact
update()
45. A Python "magic method" that returns a unicode "representation" of any object.
clear() method
__unicode__()
order_by(*fields)
Model metadata
46. 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.
Many-to-many relationship to self
delete()
choices
Entry.objects.filter(id__gt=4)
47. The database that will be used if this query is executed now
all()
db
add()
count()
48. Lookup type that returns results greater than a given value.
iteration
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
gt
reverse name
49. This model method is used for updating a ManyToManyField.
add()
select_related()
get_or_create(**kwargs)
defer(*fields)
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.
lte
reverse name
get_or_create(**kwargs)
in_bulk(id_list)