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. 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
create(**kwargs)
Abstract base class
iterator()
contains
2. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
day
default
Meta class
3. a QuerySet can be sliced - using Python's array-slicing syntax.
none()
slicing
Entry.objects.filter(id__in=[1 - 3 - 4])
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
4. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
id field
one-to-one relationship
filter(**kwargs)
delete()
5. 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.
MultipleObjectsReturned
add()
related_name
6. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
regex
Many-to-many relationship to self
relationship spanning
ordered
7. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
get_absolute_url()
==
related_name
gt
8. 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.
choices tuple
in_bulk(id_list)
order_by(*fields)
range
9. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
values(*fields)
order_by(*fields)
==
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
10. 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.
regex
Many-to-many relationship through an intermediate model
lt
default
11. A convenience method for constructing an object and saving it all in one step.
create(**kwargs)
lte
Q()
reverse name
12. 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
13. 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()
order_by(*fields)
evaluation
related_name
clear() method
14. If this option is True - the field is allowed to be blank. Default is False.
search
Entry.objects.filter(pub_date__year=2005).delete()
blank
filter chaining
15. A Python "magic method" that returns a unicode "representation" of any object.
using(alias)
get_absolute_url()
db
__unicode__()
16. 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.
delete()
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
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)
17. 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.
help_text
values_list(*fields)
when you add new apps to INSTALLED_APPS
count()
18. 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.
clear() method
using(alias)
day
delete()
19. This query finds all entries between a start date of start_date and an end date of end_date.
get_or_create(**kwargs)
|
blank
Entry.objects.filter(pub_date__range=(start_date - end_date))
20. 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
none()
model
range
Proxy model
21. Lookup type that returns results less than or equal to a given value.
lte
Field lookups
year
istartswith
22. This method immediately deletes the object and has no return value.
iendswith
get(**kwargs)
delete()
Q()
23. 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.
Many-to-many relationship through an intermediate model
annotate(args - *kwargs)
Entry.objects.filter(pub_date__year=2005).delete()
Q()
24. Lookup type that finds a case-sensitive regular expression match.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
default
blank
regex
25. Returns the object matching the given lookup parameters
Many-to-many relationship through an intermediate model
Entry.objects.filter(pub_date__range=(start_date - end_date))
get(**kwargs)
filter(**kwargs)
26. Lookup type that returns results in a given list.
clear() method
lte
get_or_create(**kwargs)
in
27. If True - this field is the primary key for the model.
primary_key
delete()
ManyToManyField
Q()
28. This query finds all entries with an id greater than 4.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
pickling
Entry.objects.filter(id__gt=4)
iteration
29. Lookup type that tests for inclusion in a case-sensitive fashion.
select_related()
contains
in_bulk(id_list)
Entry.objects.filter(pub_date__year=2005).delete()
30. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
order_by(*fields)
values(*fields)
choices tuple
iteration
31. 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
MultipleObjectsReturned
all()
Manager
istartswith
32. The default for this is the name of the child class followed by '_set'.
none()
gt
reverse name
get(**kwargs)
33. 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.
QuerySet
get_or_create(**kwargs)
help_text
choices
34. Lookup type that returns results with a case-insensitive start sequence.
get_or_create(**kwargs)
~
delete()
istartswith
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)
regex
get_or_create(**kwargs)
Model metadata
reverse()
36. This gives your model metadata.
unique
Meta class
exists()
istartswith
37. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
Field lookups
Manager
pk
pickling
38. 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.
in
Entry.objects.filter(id__gt=4)
delete()
many-to-one relationship
39. 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
40. 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
iregex
select_related()
order_by(*fields)
ordered
41. This model method is used for updating a ManyToManyField.
ManyToManyField
when you add new apps to INSTALLED_APPS
add()
week_day
42. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
count()
update()
month
Entry.objects.filter(id__in=[1 - 3 - 4])
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
get(**kwargs)
day
in_bulk(id_list)
44. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo
none()
one-to-one relationship
select_related()
gte
45. If True - the table does not permit duplicate values for this field.
unique
==
month
dates(field - kind - order='ASC')
46. 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
47. Returns a new QuerySet containing objects that match the given lookup parameters.
filter(**kwargs)
filter chaining
exists()
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
48. 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
&
Manager
range
annotate(args - *kwargs)
49. This model method saves a model instance to the database. This method has no return value.
pk
range
save()
choices
50. 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.
OneToOneField
count()
iendswith
Multi-table inheritance