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. 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
2. If this option is True - Django will store empty values as NULL in the database. Default is False.
values(*fields)
filter(**kwargs)
get_absolute_url()
null
3. 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.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
values(*fields)
choices tuple
pickling
4. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
create(**kwargs)
Many-to-many relationship to self
exclude(**kwargs)
db
5. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
using(alias)
count()
clear() method
values_list(*fields)
6. 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.
get(**kwargs)
Q()
Abstract base class
Entry.objects.filter(id__in=[1 - 3 - 4])
7. This is a criterion that narrow down a QuerySet based on given parameters.
only(*fields)
__unicode__()
year
filter
8. Lookup type that returns results less than a given value.
Meta class
lt
in_bulk(id_list)
gt
9. 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
==
endswith
defer(*fields)
10. 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
ManyToManyField
iendswith
only(*fields)
choices
11. Lookup type that yields a case-insensitive match.
model
iexact
choices tuple
isnull
12. 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
Abstract base class
pk
Entry.objects.filter(id__in=[1 - 3 - 4])
&
13. Lookup type that returns results with a case-insensitive end sequence.
Entry.objects.filter(id__gt=4)
ForeignKey
iendswith
exclude(**kwargs)
14. Fields are specified by these
default
Abstract base class
class attributes
Entry.objects.filter(id__gt=4)
15. Conjuntion operator for Q objects.
gt
distinct()
filter(**kwargs)
&
16. 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()
in
gt
blank
17. A convenience method for looking up an object with the given kwargs - creating one if necessary.
MultipleObjectsReturned
get_or_create(**kwargs)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
blank
18. This field is added automatically - but this behavior can be overridden
in
ManyToManyField
class attributes
id field
19. 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)
OneToOneField
&
Model metadata
iendswith
20. 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
select_related()
intermediate models
class attributes
all()
21. Lookup type that returns results that fall into an inclusive date range.
choices tuple
choices
gt
range
22. Exception raised by get(**kwargs) if no items match the query.
choices tuple
in
DoesNotExist
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
23. 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.
reverse name
iteration
db
help_text
24. This method immediately deletes the object and has no return value.
through argument
select_related()
delete()
using(alias)
25. 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.
exact
|
filter chaining
Custom model methods
26. If this option is True - the field is allowed to be blank. Default is False.
dates(field - kind - order='ASC')
values_list(*fields)
blank
values(*fields)
27. Lookup type that returns results in a given list.
db
in
day
ForeignKey
28. 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
default
Field lookups
iterator()
delete()
29. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
lt
gte
Proxy model
ordered
30. 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.
Entry.objects.filter(id__gt=4)
Field lookups
Multi-table inheritance
endswith
31. This gives your model metadata.
dates(field - kind - order='ASC')
Meta class
default
distinct()
32. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
filter
distinct()
QuerySet
F()
33. If True - the table does not permit duplicate values for this field.
week_day
unique
aggregate(args - *kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
34. 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.
primary_key
OneToOneField
F()
gte
35. 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.
Q(question__istartswith='What')
ForeignKey
get(**kwargs)
many-to-many relationship
36. This query deletes all Entry objects with a pub_date year of 2005.
many-to-many relationship
relationship spanning
Entry.objects.filter(pub_date__year=2005).delete()
one-to-one relationship
37. 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
select_related()
reverse()
filter(**kwargs)
save()
38. When to run syncdb
day
pk
in
when you add new apps to INSTALLED_APPS
39. Lookup type that returns results less than or equal to a given value.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
blank
related_name
lte
40. Negation operator for Q objects.
~
primary_key
get(**kwargs)
startswith
41. These methods are intended to do "table-wide" things.
week_day
help_text
Manager methods
get_or_create(**kwargs)
42. 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.
order_by(*fields)
slicing
gte
db
43. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
related_name
update(**kwargs)
exact
ForeignKey
44. 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
45. 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.
iterator()
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Model metadata
using(alias)
46. Returns the most recent object in the table - by date - using the field_name provided as the date field.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
ordered
latest(field_name=None)
gt
47. Disjunction operator for Q objects.
contains
Multi-table inheritance
|
dates(field - kind - order='ASC')
48. Lookup type that returns results greater than a given value.
gt
annotate(args - *kwargs)
==
values_list(*fields)
49. Lookup type that returns results greater than or equal to a given value.
gte
iendswith
save()
model
50. Lookup type that returns results with a case-sensitive end sequence.
endswith
exists()
OneToOneField
aggregate(args - *kwargs)