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. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
QuerySet
defer(*fields)
one-to-one relationship
get_or_create(**kwargs)
2. This gives your model metadata.
relationship spanning
when you add new apps to INSTALLED_APPS
all()
Meta class
3. 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
Proxy model
select_related()
Many-to-many relationship to self
id field
4. Used to get a QuerySet for a model. This is called 'objects' by default.
__unicode__()
Manager
create(**kwargs)
all()
5. 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
Many-to-many relationship to self
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
F()
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
6. Lookup type for date/datetime fields that finds a 'day of the week' match.
filter(**kwargs)
week_day
&
contains
7. 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
when you add new apps to INSTALLED_APPS
only(*fields)
update()
one-to-one relationship
8. 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
filter(**kwargs)
delete()
relationship spanning
Q(question__istartswith='What')
9. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
values(*fields)
F()
order_by(*fields)
Manager methods
10. Disjunction operator for Q objects.
distinct()
|
delete()
F()
11. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
none()
only(*fields)
class attributes
12. 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.
Meta class
F()
DoesNotExist
13. 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.
evaluation
Entry.objects.filter(pub_date__range=(start_date - end_date))
ForeignKey
dates(field - kind - order='ASC')
14. 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.
Proxy model
default
reverse name
all()
15. Negation operator for Q objects.
filter(**kwargs)
~
intermediate models
in_bulk(id_list)
16. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
iteration
Abstract base class
iexact
17. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
when you add new apps to INSTALLED_APPS
isnull
Manager
18. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
~
delete()
reverse()
19. 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
class attributes
day
update(**kwargs)
Abstract base class
20. A convenience method for looking up an object with the given kwargs - creating one if necessary.
reverse name
get_or_create(**kwargs)
many-to-one relationship
Manager methods
21. Lookup type that returns results less than or equal to a given value.
iexact
values_list(*fields)
lte
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
22. 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
23. Exception raised by get(**kwargs) if no items match the query.
reverse name
through argument
when you add new apps to INSTALLED_APPS
DoesNotExist
24. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
class attributes
related_name
in_bulk(id_list)
Custom model methods
25. 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.
defer(*fields)
update()
order_by(*fields)
lte
26. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
MultipleObjectsReturned
gt
month
27. 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
unique
gte
add()
Proxy model
28. The default for this is the name of the child class followed by '_set'.
evaluation
iregex
reverse name
day
29. These methods are intended to do "table-wide" things.
exclude(**kwargs)
iregex
order_by(*fields)
Manager methods
30. 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.
__unicode__()
ManyToManyField
aggregate(args - *kwargs)
Abstract base class
31. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
==
exists()
Multi-table inheritance
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
32. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
Manager methods
isnull
using(alias)
33. Lookup type for date/datetime fields that finds an exact day match.
filter chaining
day
blank
Field lookups
34. Returns a new QuerySet containing objects that match the given lookup parameters.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
year
exists()
filter(**kwargs)
35. Lookup type that returns results with a case-sensitive end sequence.
endswith
lt
order_by(*fields)
Abstract base class
36. 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.
ForeignKey
search
pickling
Custom model methods
37. If this option is True - the field is allowed to be blank. Default is False.
&
DoesNotExist
many-to-one relationship
blank
38. Fields are specified by these
class attributes
unique
aggregate(args - *kwargs)
filter chaining
39. Lookup type that returns results with a case-insensitive start sequence.
istartswith
pickling
through argument
in
40. Manager method used to retrieve every object in a model.
all()
year
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
exists()
41. If this option is True - Django will store empty values as NULL in the database. Default is False.
iendswith
in
all()
null
42. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
week_day
year
ForeignKey
slicing
43. 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.
iteration
ManyToManyField
aggregate(args - *kwargs)
pickling
44. 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
45. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
relationship spanning
MultipleObjectsReturned
endswith
46. Exception raised by get(**kwargs) if more than one item matches the query.
MultipleObjectsReturned
one-to-one relationship
Restrictions on field names
|
47. A convenience method for constructing an object and saving it all in one step.
exists()
filter(**kwargs)
create(**kwargs)
blank
48. Conjuntion operator for Q objects.
&
Entry.objects.filter(id__in=[1 - 3 - 4])
iteration
gte
49. 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.
Proxy model
lte
choices
delete()
50. 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.
search
default
using(alias)
update(**kwargs)
Sorry!:) No result found.
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