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. This gives your model metadata.
related_name
Meta class
choices
evaluation
3. Fields are specified by these
class attributes
gt
filter(**kwargs)
Entry.objects.filter(id__gt=4)
4. 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.
defer(*fields)
choices
get_absolute_url()
count()
5. 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
contains
ManyToManyField
all()
MultipleObjectsReturned
6. Lookup type that returns results that fall into an inclusive date range.
range
blank
search
get(**kwargs)
7. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
exists()
Proxy model
year
week_day
8. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
|
Entry.objects.filter(pub_date__year=2005).delete()
add()
9. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
none()
all()
one-to-one relationship
order_by(*fields)
10. The default for this is the name of the child class followed by '_set'.
related_name
DoesNotExist
pickling
reverse name
11. This model method saves a model instance to the database. This method has no return value.
create(**kwargs)
class attributes
save()
ManyToManyField
12. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Custom model methods
exact
Q(question__istartswith='What')
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
13. 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
annotate(args - *kwargs)
Manager methods
|
iexact
14. To activate your models
order_by(*fields)
pickling
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Multi-table inheritance
15. Lookup type that returns results greater than a given value.
latest(field_name=None)
pickling
db
gt
16. 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.
ManyToManyField
OneToOneField
lt
save()
17. This model method is used for updating a ManyToManyField.
Restrictions on field names
ordered
blank
add()
18. 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.
help_text
filter(**kwargs)
pickling
null
19. 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.
Manager
delete()
ManyToManyField
Abstract base class
20. Conjuntion operator for Q objects.
count()
iendswith
&
Entry.objects.filter(pub_date__range=(start_date - end_date))
21. 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.
pickling
Many-to-many relationship to self
update(**kwargs)
isnull
22. If True - this field is the primary key for the model.
QuerySet
regex
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
primary_key
23. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
select_related()
annotate(args - *kwargs)
values(*fields)
Abstract base class
24. If True - the table does not permit duplicate values for this field.
contains
unique
blank
|
25. 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.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
order_by(*fields)
choices
aggregate(args - *kwargs)
26. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
class type
using(alias)
Model metadata
27. This is a criterion that narrow down a QuerySet based on given parameters.
reverse()
filter
when you add new apps to INSTALLED_APPS
ForeignKey
28. Lookup type that returns results less than a given value.
distinct()
lt
~
pk
29. 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.
ManyToManyField
help_text
isnull
ordered
30. a QuerySet can be sliced - using Python's array-slicing syntax.
endswith
slicing
id field
pickling
31. 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
db
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
ForeignKey
32. This query finds all entries between a start date of start_date and an end date of end_date.
evaluation
Entry.objects.filter(pub_date__range=(start_date - end_date))
all()
|
33. 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)
search
F()
34. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
get(**kwargs)
id field
ordered
QuerySet
35. If this option is True - the field is allowed to be blank. Default is False.
related_name
blank
through argument
isnull
36. When to run syncdb
Custom model methods
search
when you add new apps to INSTALLED_APPS
gte
37. 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
update(**kwargs)
ForeignKey
clear() method
Abstract base class
38. Lookup type that finds a case-sensitive regular expression match.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
reverse()
filter(**kwargs)
regex
39. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r
QuerySet
filter
intermediate models
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
40. This method immediately deletes the object and has no return value.
primary_key
clear() method
id field
delete()
41. 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.
intermediate models
month
get_absolute_url()
iterator()
42. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
Q()
count()
evaluation
update(**kwargs)
43. 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
44. Keyword shortcut for looking up an object by primary key.
pk
distinct()
related_name
Multi-table inheritance
45. 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
filter chaining
related_name
class type
get_or_create(**kwargs)
46. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
distinct()
Restrictions on field names
add()
null
47. 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.
iregex
exclude(**kwargs)
latest(field_name=None)
update()
48. A convenience method for constructing an object and saving it all in one step.
clear() method
~
using(alias)
create(**kwargs)
49. 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
all()
annotate(args - *kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
50. Lookup type that returns results less than or equal to a given value.
reverse name
lte
Many-to-many relationship to self
Multi-table inheritance