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. 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.
Abstract base class
get_absolute_url()
OneToOneField
delete()
2. 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
Q()
iterator()
Proxy model
in
3. This gives your model metadata.
default
Meta class
choices
distinct()
4. Manager method used to retrieve every object in a model.
Restrictions on field names
MultipleObjectsReturned
gte
all()
5. The database that will be used if this query is executed now
blank
iexact
Field lookups
db
6. This field is added automatically - but this behavior can be overridden
gt
filter chaining
id field
iendswith
7. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
count()
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
get_absolute_url()
Field lookups
8. 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.
using(alias)
Manager
search
year
9. If True - the table does not permit duplicate values for this field.
primary_key
istartswith
unique
week_day
10. 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.
Entry.objects.filter(id__in=[1 - 3 - 4])
Field lookups
ManyToManyField
~
11. This is a criterion that narrow down a QuerySet based on given parameters.
choices tuple
F()
many-to-many relationship
filter
12. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
year
related_name
db
Entry.objects.filter(id__in=[1 - 3 - 4])
13. 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
14. 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
&
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
Entry.objects.filter(id__gt=4)
exists()
15. Lookup type that yields a case-insensitive match.
iexact
slicing
day
intermediate models
16. This query deletes all Entry objects with a pub_date year of 2005.
intermediate models
month
Entry.objects.filter(pub_date__year=2005).delete()
create(**kwargs)
17. Lookup type that finds a case-sensitive regular expression match.
regex
__unicode__()
exact
help_text
18. Lookup type that tests for inclusion in a case-sensitive fashion.
all()
contains
get(**kwargs)
exclude(**kwargs)
19. Returns a new QuerySet containing objects that match the given lookup parameters.
filter(**kwargs)
when you add new apps to INSTALLED_APPS
ManyToManyField
blank
20. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
many-to-one relationship
get_or_create(**kwargs)
model
Proxy model
21. A convenience method for constructing an object and saving it all in one step.
values(*fields)
DoesNotExist
null
create(**kwargs)
22. Keyword shortcut for looking up an object by primary key.
pk
get_or_create(**kwargs)
intermediate models
gte
23. This represents a collection of objects from your database. It can have zero - one or many filters.
through argument
when you add new apps to INSTALLED_APPS
QuerySet
Custom model methods
24. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
Many-to-many relationship through an intermediate model
search
distinct()
year
25. Lookup type that returns results greater than a given value.
MultipleObjectsReturned
gt
Entry.objects.filter(pub_date__year=2005).delete()
only(*fields)
26. 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.
QuerySet
ForeignKey
Q()
search
27. A convenience method for looking up an object with the given kwargs - creating one if necessary.
gt
year
get_or_create(**kwargs)
all()
28. This method immediately deletes the object and has no return value.
dates(field - kind - order='ASC')
Custom model methods
Entry.objects.filter(pub_date__year=2005).delete()
delete()
29. If True - this field is the primary key for the model.
==
regex
QuerySet
primary_key
30. Returns the object matching the given lookup parameters
get(**kwargs)
Restrictions on field names
iendswith
using(alias)
31. Can be used to remove all many-to-many relationships for an instance
get_absolute_url()
month
istartswith
clear() method
32. Lookup type that returns results with a case-sensitive start sequence.
week_day
regex
iregex
startswith
33. Negation operator for Q objects.
Custom model methods
filter(**kwargs)
~
Many-to-many relationship through an intermediate model
34. 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
35. This query finds all entries with an id greater than 4.
get(**kwargs)
Entry.objects.filter(id__gt=4)
delete()
ManyToManyField
36. Exception raised by get(**kwargs) if no items match the query.
reverse name
exclude(**kwargs)
exact
DoesNotExist
37. This model method is used for updating a ManyToManyField.
in_bulk(id_list)
add()
help_text
filter chaining
38. 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.
MultipleObjectsReturned
get_absolute_url()
==
regex
39. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo
ordered
relationship spanning
regex
Abstract base class
40. Lookup type that finds a case-insensitive regular expression match.
aggregate(args - *kwargs)
iregex
Custom model methods
class attributes
41. Returns the most recent object in the table - by date - using the field_name provided as the date field.
latest(field_name=None)
delete()
Custom model methods
get(**kwargs)
42. Disjunction operator for Q objects.
one-to-one relationship
|
default
all()
43. These add custom "row-level" functionality to your objects. These act on a particular model instance.
OneToOneField
Custom model methods
get(**kwargs)
Entry.objects.filter(id__gt=4)
44. 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.
isnull
week_day
default
model
45. This query finds all entries between a start date of start_date and an end date of end_date.
iendswith
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
month
Entry.objects.filter(pub_date__range=(start_date - end_date))
46. 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.
startswith
isnull
Multi-table inheritance
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
47. 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.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
Abstract base class
clear() method
choices tuple
48. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
isnull
endswith
unique
class type
49. If this option is True - the field is allowed to be blank. Default is False.
blank
regex
filter chaining
update(**kwargs)
50. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183