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. When to run syncdb
when you add new apps to INSTALLED_APPS
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Custom model methods
latest(field_name=None)
2. This is a criterion that narrow down a QuerySet based on given parameters.
values(*fields)
iteration
filter
Manager
3. Lookup type for date/datetime fields that finds an exact day match.
all()
db
QuerySet
day
4. 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)
get(**kwargs)
reverse name
pickling
5. If True - this field is the primary key for the model.
select_related()
iregex
primary_key
Restrictions on field names
6. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
filter(**kwargs)
__unicode__()
filter
save()
7. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
Restrictions on field names
isnull
default
distinct()
8. 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
iterator()
reverse()
defer(*fields)
get_absolute_url()
9. 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
Q()
create(**kwargs)
class type
all()
10. Exception raised by get(**kwargs) if no items match the query.
unique
pk
slicing
DoesNotExist
11. 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
lt
get_absolute_url()
many-to-many relationship
12. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
using(alias)
latest(field_name=None)
order_by(*fields)
==
13. This method immediately deletes the object and has no return value.
startswith
delete()
in
Many-to-many relationship through an intermediate model
14. 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.
pk
using(alias)
lte
many-to-many relationship
15. Lookup type that yields a case-insensitive match.
through argument
filter(**kwargs)
iexact
range
16. If this option is True - the field is allowed to be blank. Default is False.
blank
related_name
add()
ManyToManyField
17. Exception raised by get(**kwargs) if more than one item matches the query.
F()
none()
endswith
MultipleObjectsReturned
18. 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)
==
range
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
19. 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.
default
reverse()
OneToOneField
search
20. a QuerySet can be sliced - using Python's array-slicing syntax.
slicing
filter(**kwargs)
many-to-one relationship
regex
21. 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.
clear() method
filter(**kwargs)
search
day
22. 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.
latest(field_name=None)
filter
Multi-table inheritance
range
23. 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
24. This represents a collection of objects from your database. It can have zero - one or many filters.
get_absolute_url()
null
~
QuerySet
25. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
one-to-one relationship
Many-to-many relationship to self
id field
26. 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
latest(field_name=None)
filter(**kwargs)
Manager methods
27. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
lte
istartswith
Restrictions on field names
28. This query deletes all Entry objects with a pub_date year of 2005.
update()
id field
==
Entry.objects.filter(pub_date__year=2005).delete()
29. 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()
help_text
week_day
30. This query finds all entries with an id in the list [1 - 3 - 4]
pickling
Entry.objects.filter(id__in=[1 - 3 - 4])
F()
update(**kwargs)
31. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
all()
year
|
month
32. These methods are intended to do "table-wide" things.
delete()
Entry.objects.filter(id__gt=4)
id field
Manager methods
33. 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
none()
annotate(args - *kwargs)
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
db
34. Returns a new QuerySet containing objects that match the given lookup parameters.
delete()
in
contains
filter(**kwargs)
35. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.
iregex
class attributes
choices
Meta class
36. This query finds all entries with an id greater than 4.
ordered
when you add new apps to INSTALLED_APPS
slicing
Entry.objects.filter(id__gt=4)
37. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
get(**kwargs)
get_or_create(**kwargs)
create(**kwargs)
one-to-one relationship
38. Lookup type that returns results less than a given value.
endswith
lt
values(*fields)
week_day
39. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
in
Manager methods
update(**kwargs)
many-to-many relationship
40. 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.
ManyToManyField
aggregate(args - *kwargs)
Manager
null
41. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
count()
class attributes
isnull
db
42. The database that will be used if this query is executed now
count()
through argument
get_or_create(**kwargs)
db
43. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
class type
filter(**kwargs)
related_name
evaluation
44. Defines a many-to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model.
ForeignKey
relationship spanning
select_related()
iterator()
45. 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
help_text
Field lookups
filter chaining
through argument
46. 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
lte
null
DoesNotExist
47. Lookup type that returns results with a case-insensitive end sequence.
iendswith
aggregate(args - *kwargs)
gte
Multi-table inheritance
48. 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
49. Lookup type that returns results with a case-sensitive end sequence.
search
endswith
get_absolute_url()
day
50. 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.
Proxy model
exists()
iterator()
order_by(*fields)