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. Can be used to remove all many-to-many relationships for an instance
clear() method
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
none()
Entry.objects.filter(id__gt=4)
2. a QuerySet can be sliced - using Python's array-slicing syntax.
slicing
delete()
OneToOneField
get(**kwargs)
3. Lookup type that finds a case-sensitive regular expression match.
annotate(args - *kwargs)
lte
regex
~
4. If True - this field is the primary key for the model.
QuerySet
reverse()
day
primary_key
5. 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
through argument
only(*fields)
latest(field_name=None)
ordered
6. This gives your model metadata.
get_or_create(**kwargs)
search
Meta class
id field
7. 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.
many-to-one relationship
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
Manager methods
regex
8. If this option is True - the field is allowed to be blank. Default is False.
help_text
blank
delete()
through argument
9. 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.
distinct()
isnull
get_absolute_url()
startswith
10. Lookup type that yields a case-insensitive match.
__unicode__()
iexact
filter
endswith
11. 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
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
count()
MultipleObjectsReturned
through argument
12. This method immediately deletes the object and has no return value.
iterator()
save()
delete()
default
13. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
regex
Manager methods
filter(**kwargs)
14. 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.
using(alias)
Abstract base class
isnull
OneToOneField
15. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Many-to-many relationship through an intermediate model
through argument
year
16. 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
17. To activate your models
gt
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
in_bulk(id_list)
Manager methods
18. Lookup type that tests for inclusion in a case-sensitive fashion.
null
contains
class type
isnull
19. 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
relationship spanning
Manager methods
using(alias)
20. 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.
lte
choices
search
evaluation
21. Lookup type that returns results greater than or equal to a given value.
many-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.
gte
in
22. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
DoesNotExist
all()
delete()
23. 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.
F()
__unicode__()
when you add new apps to INSTALLED_APPS
reverse()
24. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__gt=4)
related_name
Entry.objects.filter(id__in=[1 - 3 - 4])
values_list(*fields)
25. 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_bulk(id_list)
Q(question__istartswith='What')
OneToOneField
choices
26. The default for this is the name of the child class followed by '_set'.
reverse name
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
get_absolute_url()
Multi-table inheritance
27. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
distinct()
Proxy model
get(**kwargs)
ForeignKey
28. 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
endswith
id field
defer(*fields)
Meta class
29. If True - the table does not permit duplicate values for this field.
unique
none()
default
Entry.objects.filter(id__in=[1 - 3 - 4])
30. 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
31. Lookup type for date/datetime fields that finds an exact day match.
lt
day
many-to-one relationship
primary_key
32. 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
33. Lookup type that returns results less than a given value.
lt
Custom model methods
DoesNotExist
istartswith
34. Disjunction operator for Q objects.
exclude(**kwargs)
|
get(**kwargs)
lte
35. This field is added automatically - but this behavior can be overridden
Entry.objects.filter(id__gt=4)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
one-to-one relationship
id field
36. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
search
values(*fields)
many-to-many relationship
choices
37. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()
evaluation
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
clear() method
Many-to-many relationship to self
38. 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
~
get_absolute_url()
choices
intermediate models
39. Exception raised by get(**kwargs) if more than one item matches the query.
MultipleObjectsReturned
range
clear() method
primary_key
40. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
save()
Manager
delete()
exclude(**kwargs)
41. This is a criterion that narrow down a QuerySet based on given parameters.
filter(**kwargs)
model
in_bulk(id_list)
filter
42. Manager method used to retrieve every object in a model.
exists()
when you add new apps to INSTALLED_APPS
all()
ordered
43. 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.
filter(**kwargs)
blank
through argument
Many-to-many relationship to self
44. Lookup type that returns results with a case-sensitive start sequence.
search
class attributes
startswith
==
45. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.
filter chaining
get_or_create(**kwargs)
clear() method
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
46. 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.
Meta class
~
F()
pickling
47. Negation operator for Q objects.
defer(*fields)
all()
~
id field
48. This model method saves a model instance to the database. This method has no return value.
save()
one-to-one relationship
get_absolute_url()
null
49. 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
in_bulk(id_list)
related_name
Abstract base class
Many-to-many relationship to self
50. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
Manager methods
values(*fields)
exists()
blank