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 method immediately deletes the object and has no return value.
model
class type
Proxy model
delete()
2. Can be used to remove all many-to-many relationships for an instance
iendswith
clear() method
select_related()
Many-to-many relationship to self
3. Lookup type that returns results with a case-sensitive start sequence.
startswith
add()
order_by(*fields)
gte
4. Used to get a QuerySet for a model. This is called 'objects' by default.
Entry.objects.filter(id__in=[1 - 3 - 4])
startswith
Manager
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
5. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
Manager methods
model
null
6. Lookup type that finds a case-sensitive regular expression match.
QuerySet
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
regex
using(alias)
7. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
filter(**kwargs)
MultipleObjectsReturned
class type
iexact
8. Lookup type that returns results less than or equal to a given value.
lte
distinct()
filter
select_related()
9. 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
through argument
update(**kwargs)
many-to-one relationship
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
10. 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.
Many-to-many relationship through an intermediate model
one-to-one relationship
help_text
&
11. To activate your models
slicing
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)
many-to-many relationship
12. Lookup type that returns results with a case-sensitive end sequence.
lt
range
endswith
slicing
13. 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
14. 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.
filter(**kwargs)
contains
through argument
help_text
15. 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.
update()
isnull
F()
range
16. Exception raised by get(**kwargs) if no items match the query.
Entry.objects.filter(id__gt=4)
DoesNotExist
create(**kwargs)
delete()
17. If this option is True - Django will store empty values as NULL in the database. Default is False.
none()
null
gt
Entry.objects.filter(id__gt=4)
18. Lookup type that returns results greater than a given value.
many-to-many relationship
gt
&
iexact
19. 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
values(*fields)
distinct()
__unicode__()
20. 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
one-to-one relationship
values_list(*fields)
many-to-many relationship
update(**kwargs)
21. Lookup type that returns results that fall into an inclusive date range.
range
istartswith
Manager methods
many-to-one relationship
22. 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.
delete()
Restrictions on field names
class type
Entry.objects.filter(pub_date__year=2005).delete()
23. This field is added automatically - but this behavior can be overridden
reverse name
lt
id field
Entry.objects.filter(pub_date__range=(start_date - end_date))
24. 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
exists()
slicing
iterator()
Entry.objects.filter(pub_date__year=2005).delete()
25. 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
DoesNotExist
ordered
update(**kwargs)
iterator()
26. If this option is True - the field is allowed to be blank. Default is False.
blank
ordered
contains
using(alias)
27. The database that will be used if this query is executed now
Entry.objects.filter(id__gt=4)
save()
db
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
28. 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.
search
pickling
all()
create(**kwargs)
29. Conjuntion operator for Q objects.
day
primary_key
&
exact
30. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
update(**kwargs)
save()
values(*fields)
|
31. This query uses an F object to increment the pingback count for every entry in the blog.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
32. Lookup type that returns results greater than or equal to a given value.
Entry.objects.filter(id__in=[1 - 3 - 4])
iterator()
gte
Many-to-many relationship through an intermediate model
33. 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.
endswith
Entry.objects.filter(pub_date__year=2005).delete()
values_list(*fields)
latest(field_name=None)
34. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
order_by(*fields)
Manager
&
distinct()
35. 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()
evaluation
all()
iendswith
~
36. These add custom "row-level" functionality to your objects. These act on a particular model instance.
values_list(*fields)
search
Custom model methods
DoesNotExist
37. (1) These cannot be Python reserved words - because that would result in a Python syntax error. (2) These cannot contain more than one underscore in a row - due to the way Django's query lookup syntax works.
Restrictions on field names
Multi-table inheritance
Entry.objects.filter(pub_date__year=2005).delete()
add()
38. 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
Entry.objects.filter(id__in=[1 - 3 - 4])
search
Proxy model
dates(field - kind - order='ASC')
39. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
Meta class
count()
related_name
using(alias)
40. Returns the object matching the given lookup parameters
range
get(**kwargs)
create(**kwargs)
QuerySet
41. Lookup type that tests for inclusion in a case-sensitive fashion.
gt
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
contains
latest(field_name=None)
42. This query finds all entries with an id greater than 4.
Meta class
add()
Restrictions on field names
Entry.objects.filter(id__gt=4)
43. Lookup type that returns results with a case-insensitive start sequence.
reverse name
many-to-one relationship
istartswith
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
44. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
regex
isnull
Q(question__istartswith='What')
class type
45. A Python "magic method" that returns a unicode "representation" of any object.
choices tuple
__unicode__()
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
month
46. This gives your model metadata.
add()
Meta class
exists()
select_related()
47. Lookup type that returns results less than a given value.
get(**kwargs)
day
lt
contains
48. Lookup type that returns results in a given list.
exists()
values(*fields)
filter(**kwargs)
in
49. If True - this field is the primary key for the model.
isnull
DoesNotExist
primary_key
filter(**kwargs)
50. This represents a collection of objects from your database. It can have zero - one or many filters.
iterator()
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
QuerySet
Proxy model
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