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 finds all entries between a start date of start_date and an end date of end_date.
iendswith
save()
Entry.objects.filter(pub_date__range=(start_date - end_date))
reverse()
2. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
many-to-many relationship
reverse name
related_name
Entry.objects.filter(id__in=[1 - 3 - 4])
3. 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
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
annotate(args - *kwargs)
iterator()
4. Exception raised by get(**kwargs) if no items match the query.
delete()
&
DoesNotExist
ManyToManyField
5. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
distinct()
related_name
MultipleObjectsReturned
pickling
6. 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.
filter chaining
get_absolute_url()
many-to-one relationship
month
7. To activate your models
update(**kwargs)
gte
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
gt
8. Lookup type that returns results with a case-insensitive end sequence.
week_day
null
iendswith
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
9. 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.
through argument
order_by(*fields)
choices
model
10. Lookup type that finds a case-sensitive regular expression match.
iterator()
filter
regex
clear() method
11. 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.
Manager methods
OneToOneField
Field lookups
exact
12. A Python "magic method" that returns a unicode "representation" of any object.
many-to-one relationship
MultipleObjectsReturned
pickling
__unicode__()
13. This represents a collection of objects from your database. It can have zero - one or many filters.
QuerySet
in_bulk(id_list)
blank
exists()
14. Lookup type for date/datetime fields that finds a 'day of the week' match.
values(*fields)
week_day
dates(field - kind - order='ASC')
in
15. The default for this is the name of the child class followed by '_set'.
__unicode__()
reverse name
==
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
16. Here - you can't use add - create - or assignment (i.e. - beatles.members = [...]) to create relationships. You need to specify all the detail for the relationship required by the intermediate model.
in_bulk(id_list)
iendswith
OneToOneField
Many-to-many relationship through an intermediate model
17. 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.
Entry.objects.filter(id__in=[1 - 3 - 4])
pickling
Q()
defer(*fields)
18. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Custom model methods
class attributes
week_day
related_name
19. 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
Model metadata
Proxy model
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
20. 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.all().update(n_pingbacks=F('n_pingbacks') + 1)
exists()
defer(*fields)
id field
21. Lookup type that returns results greater than or equal to a given value.
iendswith
==
gte
many-to-many relationship
22. If this option is True - the field is allowed to be blank. Default is False.
Proxy model
blank
unique
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
23. 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
24. Lookup type that returns results less than a given value.
lt
select_related()
Model metadata
Abstract base class
25. 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.
only(*fields)
get(**kwargs)
ManyToManyField
search
26. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
choices
gt
dates(field - kind - order='ASC')
values(*fields)
27. 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.
Entry.objects.filter(pub_date__year=2005).delete()
id field
get(**kwargs)
in
28. Lookup type that yields a case-insensitive match.
Restrictions on field names
gte
lte
iexact
29. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
Entry.objects.filter(id__in=[1 - 3 - 4])
related_name
range
30. This object allows you to compare the value of a model field with another field on the same model. Django supports the use of addition - subtraction - multiplication - division and modulo arithmetic with these objects - both with constants and with o
db
unique
F()
&
31. If this option is True - Django will store empty values as NULL in the database. Default is False.
QuerySet
F()
null
filter
32. 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
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
exclude(**kwargs)
select_related()
choices tuple
33. The database that will be used if this query is executed now
search
add()
db
update(**kwargs)
34. Lookup type that returns results with a case-insensitive start sequence.
get(**kwargs)
istartswith
Many-to-many relationship to self
dates(field - kind - order='ASC')
35. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
add()
get(**kwargs)
isnull
ForeignKey
36. 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.
ForeignKey
delete()
using(alias)
Many-to-many relationship to self
37. 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
contains
all()
ManyToManyField
values(*fields)
38. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
choices
istartswith
delete()
year
39. 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)
istartswith
Model metadata
filter chaining
default
40. This method immediately deletes the object and has no return value.
Entry.objects.filter(pub_date__year=2005).delete()
delete()
in_bulk(id_list)
latest(field_name=None)
41. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.
Custom model methods
pk
through argument
update()
42. 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.
update()
default
Meta class
in_bulk(id_list)
43. This model method is used for updating a ManyToManyField.
startswith
update()
add()
QuerySet
44. 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.
Abstract base class
get(**kwargs)
help_text
exact
45. 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.
Model metadata
filter(**kwargs)
clear() method
values_list(*fields)
46. Lookup type that returns results in a given list.
lt
clear() method
aggregate(args - *kwargs)
in
47. Returns the most recent object in the table - by date - using the field_name provided as the date field.
latest(field_name=None)
related_name
default
Q()
48. Lookup type that returns results greater than a given value.
Proxy model
update(**kwargs)
gte
gt
49. Lookup type that returns results with a case-sensitive start sequence.
Q(question__istartswith='What')
exclude(**kwargs)
intermediate models
startswith
50. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F
update(**kwargs)
iregex
annotate(args - *kwargs)
gte
Can you answer 50 questions in 15 minutes?
Let me suggest you:
Browse all subjects
Browse all tests
Most popular tests
Major Subjects
Tests & Exams
AP
CLEP
DSST
GRE
SAT
GMAT
Certifications
CISSP go to https://www.isc2.org/
PMP
ITIL
RHCE
MCTS
More...
IT Skills
Android Programming
Data Modeling
Objective C Programming
Basic Python Programming
Adobe Illustrator
More...
Business Skills
Advertising Techniques
Business Accounting Basics
Business Strategy
Human Resource Management
Marketing Basics
More...
Soft Skills
Body Language
People Skills
Public Speaking
Persuasion
Job Hunting And Resumes
More...
Vocabulary
GRE Vocab
SAT Vocab
TOEFL Essential Vocab
Basic English Words For All
Global Words You Should Know
Business English
More...
Languages
AP German Vocab
AP Latin Vocab
SAT Subject Test: French
Italian Survival
Norwegian Survival
More...
Engineering
Audio Engineering
Computer Science Engineering
Aerospace Engineering
Chemical Engineering
Structural Engineering
More...
Health Sciences
Basic Nursing Skills
Health Science Language Fundamentals
Veterinary Technology Medical Language
Cardiology
Clinical Surgery
More...
English
Grammar Fundamentals
Literary And Rhetorical Vocab
Elements Of Style Vocab
Introduction To English Major
Complete Advanced Sentences
Literature
Homonyms
More...
Math
Algebra Formulas
Basic Arithmetic: Measurements
Metric Conversions
Geometric Properties
Important Math Facts
Number Sense Vocab
Business Math
More...
Other Major Subjects
Science
Economics
History
Law
Performing-arts
Cooking
Logic & Reasoning
Trivia
Browse all subjects
Browse all tests
Most popular tests