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. 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.
istartswith
iteration
aggregate(args - *kwargs)
ordered
2. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
add()
==
day
3. Lookup type that returns results with a case-sensitive start sequence.
OneToOneField
get(**kwargs)
startswith
Entry.objects.filter(id__gt=4)
4. 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
class type
Custom model methods
week_day
add()
5. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
Field lookups
month
lt
pickling
6. 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.
values_list(*fields)
exclude(**kwargs)
choices
Restrictions on field names
7. Exception raised by get(**kwargs) if more than one item matches the query.
Entry.objects.filter(id__in=[1 - 3 - 4])
delete()
choices tuple
MultipleObjectsReturned
8. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.
Q()
reverse()
blank
MultipleObjectsReturned
9. 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.
help_text
Entry.objects.filter(pub_date__year=2005).delete()
ManyToManyField
default
10. This represents a collection of objects from your database. It can have zero - one or many filters.
Restrictions on field names
delete()
MultipleObjectsReturned
QuerySet
11. 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.
distinct()
values_list(*fields)
default
OneToOneField
12. 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.
delete()
reverse()
Proxy model
Meta class
13. These methods are intended to do "table-wide" things.
==
regex
Manager methods
ManyToManyField
14. Lookup type that returns results with a case-sensitive end sequence.
endswith
Abstract base class
gt
Proxy model
15. 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.
update()
using(alias)
filter(**kwargs)
through argument
16. 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
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
defer(*fields)
filter chaining
Proxy model
17. 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.
related_name
Multi-table inheritance
Entry.objects.filter(pub_date__year=2005).delete()
month
18. This gives your model metadata.
using(alias)
blank
Meta class
related_name
19. A convenience method for constructing an object and saving it all in one step.
create(**kwargs)
Meta class
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
endswith
20. Lookup type that returns results greater than or equal to a given value.
gte
intermediate models
Manager methods
db
21. 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.
Entry.objects.filter(id__in=[1 - 3 - 4])
~
choices tuple
related_name
22. This is a criterion that narrow down a QuerySet based on given parameters.
year
ManyToManyField
filter
gte
23. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
Model metadata
save()
slicing
exclude(**kwargs)
24. Lookup type that yields a case-insensitive match.
pickling
lt
iteration
iexact
25. Fields are specified by these
class attributes
ForeignKey
exact
&
26. 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.
exists()
iendswith
pickling
unique
27. 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
through argument
get(**kwargs)
Model metadata
Manager methods
28. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
Entry.objects.filter(pub_date__range=(start_date - end_date))
values_list(*fields)
Q(question__istartswith='What')
distinct()
29. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
update(**kwargs)
Proxy model
==
30. Lookup type that returns results less than a given value.
id field
latest(field_name=None)
filter(**kwargs)
lt
31. 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
Many-to-many relationship to self
defer(*fields)
reverse()
exists()
32. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F
iregex
update(**kwargs)
iendswith
Entry.objects.filter(pub_date__range=(start_date - end_date))
33. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
lte
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
create(**kwargs)
ordered
34. When to run syncdb
choices
&
DoesNotExist
when you add new apps to INSTALLED_APPS
35. These are "anything that's not a field" - such as ordering options (ordering) - database table name (db_table) - or human-readable singular and plural names (verbose_name and verbose_name_plural)
pickling
DoesNotExist
Model metadata
get_absolute_url()
36. Keyword shortcut for looking up an object by primary key.
__unicode__()
pk
one-to-one relationship
many-to-one relationship
37. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
one-to-one relationship
ManyToManyField
Entry.objects.filter(id__in=[1 - 3 - 4])
get(**kwargs)
38. This query finds all entries between a start date of start_date and an end date of end_date.
choices tuple
search
Entry.objects.filter(pub_date__range=(start_date - end_date))
get_or_create(**kwargs)
39. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
slicing
help_text
choices
40. 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.
create(**kwargs)
class attributes
dates(field - kind - order='ASC')
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
41. Conjuntion operator for Q objects.
Entry.objects.filter(id__in=[1 - 3 - 4])
&
get(**kwargs)
delete()
42. 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
iteration
reverse name
relationship spanning
~
43. Lookup type that returns results in a given list.
reverse()
Entry.objects.filter(pub_date__year=2005).delete()
in
count()
44. 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
distinct()
filter(**kwargs)
Proxy model
Meta class
45. Lookup type that returns results with a case-insensitive end sequence.
iendswith
OneToOneField
update(**kwargs)
pk
46. To activate your models
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
choices
delete()
get(**kwargs)
47. Lookup type that finds a case-insensitive regular expression match.
iregex
iterator()
exists()
through argument
48. Exception raised by get(**kwargs) if no items match the query.
exclude(**kwargs)
DoesNotExist
Entry.objects.filter(pub_date__range=(start_date - end_date))
get(**kwargs)
49. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.
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
startswith
get_or_create(**kwargs)
evaluation
F()