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 represents a collection of objects from your database. It can have zero - one or many filters.
class attributes
reverse()
QuerySet
add()
2. 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
3. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r
endswith
Manager methods
intermediate models
none()
4. This model method is used for updating a ManyToManyField.
blank
MultipleObjectsReturned
order_by(*fields)
add()
5. Returns a new QuerySet containing objects that match the given lookup parameters.
clear() method
iterator()
exists()
filter(**kwargs)
6. Lookup type that returns results less than or equal to a given value.
lte
delete()
week_day
values(*fields)
7. 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
8. If this option is True - the field is allowed to be blank. Default is False.
filter
isnull
Q(question__istartswith='What')
blank
9. Lookup type that returns results greater than a given value.
Many-to-many relationship to self
gt
istartswith
add()
10. Lookup type that yields a case-insensitive match.
iterator()
through argument
Custom model methods
iexact
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.
OneToOneField
slicing
QuerySet
delete()
12. 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
istartswith
lt
blank
13. 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
Model metadata
exists()
MultipleObjectsReturned
endswith
14. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
unique
regex
distinct()
values(*fields)
15. 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
dates(field - kind - order='ASC')
class type
primary_key
16. 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
values(*fields)
delete()
class type
gte
17. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
year
Entry.objects.filter(pub_date__year=2005).delete()
QuerySet
related_name
18. (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.
week_day
QuerySet
Restrictions on field names
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
19. If True - this field is the primary key for the model.
update()
unique
primary_key
none()
20. A Python "magic method" that returns a unicode "representation" of any object.
|
null
__unicode__()
distinct()
21. 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
relationship spanning
lte
latest(field_name=None)
Manager
22. 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.
db
month
values_list(*fields)
ManyToManyField
23. 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
help_text
only(*fields)
gte
aggregate(args - *kwargs)
24. Exception raised by get(**kwargs) if no items match the query.
id field
DoesNotExist
one-to-one relationship
lt
25. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
values_list(*fields)
exact
count()
Entry.objects.filter(id__gt=4)
26. Lookup type that returns results with a case-insensitive end sequence.
in_bulk(id_list)
isnull
model
iendswith
27. This class type is useful when you just want to use the parent class to hold information that you don't want to have to type out for each child model. This class isn't going to ever be used in isolation. When it is used as a base class for other mode
OneToOneField
order_by(*fields)
DoesNotExist
Abstract base class
28. 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
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
filter(**kwargs)
update(**kwargs)
all()
29. Lookup type that returns results with a case-sensitive start sequence.
clear() method
startswith
Field lookups
Q()
30. Lookup type that returns results less than a given value.
annotate(args - *kwargs)
related_name
|
lt
31. Lookup type that finds a case-sensitive regular expression match.
all()
select_related()
regex
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
32. 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.
Many-to-many relationship to self
reverse name
using(alias)
33. Fields are specified by these
Entry.objects.filter(pub_date__range=(start_date - end_date))
istartswith
MultipleObjectsReturned
class attributes
34. 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
lte
F()
Q(question__istartswith='What')
Multi-table inheritance
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()
add()
evaluation
latest(field_name=None)
get(**kwargs)
36. 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)
aggregate(args - *kwargs)
Restrictions on field names
Model metadata
Proxy model
37. Lookup type that tests for inclusion in a case-sensitive fashion.
get_or_create(**kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
contains
iregex
38. Lookup type that returns results with a case-sensitive end sequence.
Meta class
intermediate models
id field
endswith
39. 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
primary_key
evaluation
annotate(args - *kwargs)
Entry.objects.filter(pub_date__year=2005).delete()
40. 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.
related_name
latest(field_name=None)
gte
using(alias)
41. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
iregex
class type
Q()
many-to-many relationship
42. This query finds all entries between a start date of start_date and an end date of end_date.
Entry.objects.filter(pub_date__range=(start_date - end_date))
values(*fields)
~
pickling
43. This field is added automatically - but this behavior can be overridden
==
when you add new apps to INSTALLED_APPS
annotate(args - *kwargs)
id field
44. Conjuntion operator for Q objects.
&
exclude(**kwargs)
pk
ForeignKey
45. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
==
|
unique
annotate(args - *kwargs)
46. a QuerySet can be sliced - using Python's array-slicing syntax.
order_by(*fields)
slicing
values(*fields)
update()
47. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
regex
Q()
filter chaining
48. 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
Field lookups
month
all()
update(**kwargs)
49. Lookup type that returns results greater than or equal to a given value.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
order_by(*fields)
values(*fields)
gte
50. Use this method to reverse the order in which a queryset's elements are returned. Calling this method a second time restores the ordering back to the normal direction.
only(*fields)
values_list(*fields)
none()
reverse()
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