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. The database that will be used if this query is executed now
db
count()
primary_key
MultipleObjectsReturned
2. These methods are intended to do "table-wide" things.
Manager methods
reverse name
id field
using(alias)
3. Negation operator for Q objects.
class type
~
gte
F()
4. Lookup type that finds a case-insensitive regular expression match.
only(*fields)
pk
values(*fields)
iregex
5. This model method is used for updating a ManyToManyField.
aggregate(args - *kwargs)
add()
distinct()
related_name
6. Returns the object matching the given lookup parameters
get(**kwargs)
default
only(*fields)
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
7. 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.
relationship spanning
Model metadata
default
Custom model methods
8. 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.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
ForeignKey
many-to-one relationship
aggregate(args - *kwargs)
9. 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
add()
MultipleObjectsReturned
get(**kwargs)
defer(*fields)
10. Lookup type that returns results less than or equal to a given value.
Many-to-many relationship to self
lte
ForeignKey
unique
11. 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()
pk
Q(question__istartswith='What')
12. 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.
using(alias)
get_or_create(**kwargs)
all()
reverse name
13. 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)
iteration
many-to-many relationship
latest(field_name=None)
Model metadata
14. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
distinct()
iterator()
Entry.objects.filter(id__gt=4)
when you add new apps to INSTALLED_APPS
15. This query deletes all Entry objects with a pub_date year of 2005.
distinct()
endswith
exact
Entry.objects.filter(pub_date__year=2005).delete()
16. 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.
week_day
update(**kwargs)
delete()
Multi-table inheritance
17. 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.
class attributes
Entry.objects.filter(id__in=[1 - 3 - 4])
help_text
Abstract base class
18. The default for this is the name of the child class followed by '_set'.
Q()
help_text
reverse name
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
19. Disjunction operator for Q objects.
Model metadata
blank
|
only(*fields)
20. 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
ManyToManyField
annotate(args - *kwargs)
get(**kwargs)
db
21. When to run syncdb
save()
when you add new apps to INSTALLED_APPS
==
week_day
22. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
Manager methods
class attributes
year
values(*fields)
23. Lookup type that returns results greater than a given value.
week_day
filter(**kwargs)
Model metadata
gt
24. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
ForeignKey
many-to-many relationship
one-to-one relationship
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
25. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.
choices tuple
null
none()
search
26. 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
only(*fields)
Abstract base class
Entry.objects.filter(pub_date__range=(start_date - end_date))
related_name
27. Lookup type that returns results with a case-sensitive end sequence.
endswith
get(**kwargs)
startswith
distinct()
28. 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
29. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
dates(field - kind - order='ASC')
Manager
reverse()
==
30. 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
unique
~
intermediate models
blank
31. 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.
values(*fields)
range
pickling
ManyToManyField
32. Conjuntion operator for Q objects.
Entry.objects.filter(id__gt=4)
&
==
Many-to-many relationship to self
33. 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
QuerySet
select_related()
day
delete()
34. 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
35. Lookup type that returns results with a case-insensitive start sequence.
istartswith
contains
using(alias)
week_day
36. 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
help_text
class type
filter
pickling
37. This field is added automatically - but this behavior can be overridden
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
id field
Multi-table inheritance
order_by(*fields)
38. Returns the most recent object in the table - by date - using the field_name provided as the date field.
latest(field_name=None)
related_name
gte
startswith
39. This is a criterion that narrow down a QuerySet based on given parameters.
filter
gte
using(alias)
choices
40. Lookup type that returns results less than a given value.
count()
Restrictions on field names
lt
~
41. 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
get_or_create(**kwargs)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
exists()
endswith
42. Lookup type that returns results that fall into an inclusive date range.
filter(**kwargs)
iteration
class attributes
range
43. Lookup type that yields a case-insensitive match.
day
iexact
Model metadata
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
44. 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.
lt
Meta class
pickling
choices tuple
45. 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.
in
filter(**kwargs)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
in_bulk(id_list)
46. 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
Meta class
pk
choices
all()
47. 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.
evaluation
order_by(*fields)
exists()
&
48. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
related_name
reverse()
exists()
all()
49. 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.
Restrictions on field names
range
count()
50. This query finds all entries with an id greater than 4.
iregex
|
Entry.objects.filter(id__gt=4)
MultipleObjectsReturned