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 that fall into an inclusive date range.
iregex
choices tuple
range
values_list(*fields)
2. 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.
Entry.objects.filter(pub_date__range=(start_date - end_date))
Entry.objects.filter(pub_date__year=2005).delete()
help_text
many-to-one relationship
3. 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()
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
relationship spanning
Multi-table inheritance
4. Fields are specified by these
filter(**kwargs)
Manager methods
select_related()
class attributes
5. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
clear() method
update(**kwargs)
get(**kwargs)
count()
6. Lookup type that returns results less than or equal to a given value.
filter chaining
iexact
count()
lte
7. This query finds all entries with an id greater than 4.
DoesNotExist
aggregate(args - *kwargs)
Entry.objects.filter(id__gt=4)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
8. Lookup type that returns results with a case-insensitive end sequence.
isnull
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
annotate(args - *kwargs)
iendswith
9. 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
create(**kwargs)
add()
F()
choices tuple
10. This gives your model metadata.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
aggregate(args - *kwargs)
id field
Meta class
11. Lookup type that returns results less than a given value.
lt
primary_key
Restrictions on field names
intermediate models
12. 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.
Entry.objects.filter(pub_date__range=(start_date - end_date))
get(**kwargs)
|
MultipleObjectsReturned
13. 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(**kwargs)
Many-to-many relationship to self
class type
choices
14. 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()
default
Entry.objects.filter(id__gt=4)
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
15. The default for this is the name of the child class followed by '_set'.
reverse name
only(*fields)
Proxy model
|
16. This model method saves a model instance to the database. This method has no return value.
F()
save()
many-to-many relationship
intermediate models
17. To activate your models
through argument
startswith
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
choices tuple
18. Negation operator for Q objects.
lte
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
~
ForeignKey
19. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
choices tuple
Meta class
month
Custom model methods
20. 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.
filter(**kwargs)
create(**kwargs)
many-to-one relationship
istartswith
21. Used to get a QuerySet for a model. This is called 'objects' by default.
one-to-one relationship
Manager
delete()
Q(question__istartswith='What')
22. The database that will be used if this query is executed now
select_related()
db
iregex
choices tuple
23. (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.
DoesNotExist
relationship spanning
Restrictions on field names
aggregate(args - *kwargs)
24. 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
25. Exception raised by get(**kwargs) if more than one item matches the query.
help_text
choices tuple
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
MultipleObjectsReturned
26. This method is more or less the opposite of defer(). You call it with the fields that should not be deferred when retrieving a model. If you have a model where almost all the fields need to be deferred - using this method to specify the complementary
only(*fields)
blank
iendswith
choices
27. Returns the most recent object in the table - by date - using the field_name provided as the date field.
Q()
latest(field_name=None)
iexact
distinct()
28. A Python "magic method" that returns a unicode "representation" of any object.
update(**kwargs)
QuerySet
intermediate models
__unicode__()
29. Returns True if the QuerySet contains any results - and False if not. This tries to perform the query in the simplest and fastest way possible - but it does execute nearly the same query. This means that calling this method on a queryset is faster th
month
exists()
Entry.objects.filter(id__gt=4)
pk
30. Conjuntion operator for Q objects.
Multi-table inheritance
DoesNotExist
&
count()
31. 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.
iteration
relationship spanning
order_by(*fields)
ManyToManyField
32. 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
Manager
iterator()
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
33. This model method is used for updating a ManyToManyField.
Manager methods
regex
exists()
add()
34. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
iterator()
model
iregex
Entry.objects.filter(pub_date__range=(start_date - end_date))
35. These add custom "row-level" functionality to your objects. These act on a particular model instance.
reverse name
evaluation
Custom model methods
lt
36. Lookup type that finds a case-sensitive regular expression match.
choices
Q(question__istartswith='What')
primary_key
regex
37. 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.
help_text
exact
gte
ForeignKey
38. Lookup type that finds a case-insensitive regular expression match.
iregex
many-to-one relationship
exact
default
39. 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.
count()
relationship spanning
unique
pickling
40. 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.
F()
using(alias)
lte
gte
41. 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
42. Can be used to remove all many-to-many relationships for an instance
clear() method
Entry.objects.filter(pub_date__range=(start_date - end_date))
Manager
iteration
43. Lookup type for date/datetime fields that finds a 'day of the week' match.
in_bulk(id_list)
relationship spanning
week_day
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
44. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
month
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
MultipleObjectsReturned
45. 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.
lte
Q()
pickling
values_list(*fields)
46. If True - this field is the primary key for the model.
lt
null
primary_key
year
47. If this option is True - Django will store empty values as NULL in the database. Default is False.
Entry.objects.filter(pub_date__year=2005).delete()
class attributes
update()
null
48. Lookup type that returns results with a case-sensitive end sequence.
intermediate models
isnull
__unicode__()
endswith
49. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
reverse name
istartswith
Entry.objects.filter(id__in=[1 - 3 - 4])
50. 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.
aggregate(args - *kwargs)
delete()
pickling
exact