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. If True - the table does not permit duplicate values for this field.
MultipleObjectsReturned
unique
lt
filter chaining
2. These methods are intended to do "table-wide" things.
many-to-many relationship
Manager methods
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
==
3. If this option is True - Django will store empty values as NULL in the database. Default is False.
regex
primary_key
week_day
null
4. Lookup type that returns results with a case-insensitive start sequence.
istartswith
choices tuple
iterator()
QuerySet
5. Disjunction operator for Q objects.
|
~
filter(**kwargs)
help_text
6. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo
none()
null
filter(**kwargs)
MultipleObjectsReturned
7. Lookup type that finds a case-sensitive regular expression match.
null
reverse name
regex
pk
8. 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
ordered
MultipleObjectsReturned
all()
only(*fields)
9. 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
range
select_related()
slicing
intermediate models
10. 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
11. This query deletes all Entry objects with a pub_date year of 2005.
iexact
Entry.objects.filter(id__in=[1 - 3 - 4])
month
Entry.objects.filter(pub_date__year=2005).delete()
12. Lookup type that returns results less than or equal to a given value.
class type
lte
Model metadata
MultipleObjectsReturned
13. 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.
get_absolute_url()
&
intermediate models
contains
14. Defined by django.db.models.ForeignKey. You use it just like any other Field type: by including it as a class attribute of your model.
get(**kwargs)
Manager
related_name
many-to-one relationship
15. Exception raised by get(**kwargs) if more than one item matches the query.
get_absolute_url()
Entry.objects.filter(pub_date__year=2005).delete()
MultipleObjectsReturned
dates(field - kind - order='ASC')
16. 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.
pickling
Entry.objects.filter(id__gt=4)
all()
Many-to-many relationship to self
17. 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)
Many-to-many relationship to self
model
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Model metadata
18. This gives your model metadata.
Meta class
reverse()
Entry.objects.filter(id__in=[1 - 3 - 4])
save()
19. This is a criterion that narrow down a QuerySet based on given parameters.
iteration
range
filter
blank
20. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
values(*fields)
default
class type
21. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
pickling
Multi-table inheritance
primary_key
Field lookups
22. Takes a list of primary-key values and returns a dictionary mapping each primary-key value to an instance of the object with the given ID.
count()
in_bulk(id_list)
gte
filter chaining
23. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
one-to-one relationship
delete()
class attributes
Manager methods
24. Keyword shortcut for looking up an object by primary key.
count()
DoesNotExist
Custom model methods
pk
25. This represents a collection of objects from your database. It can have zero - one or many filters.
QuerySet
lt
isnull
save()
26. Conjuntion operator for Q objects.
iendswith
iregex
&
gte
27. This model method saves a model instance to the database. This method has no return value.
save()
Model metadata
choices
one-to-one relationship
28. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
choices tuple
get_or_create(**kwargs)
values(*fields)
class attributes
29. 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.
Entry.objects.filter(pub_date__range=(start_date - end_date))
week_day
|
OneToOneField
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
F()
Entry.objects.filter(pub_date__range=(start_date - end_date))
Meta class
week_day
31. Lookup type that tests for inclusion in a case-sensitive fashion.
|
contains
model
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
32. 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.
filter(**kwargs)
search
all()
slicing
33. Used to get a QuerySet for a model. This is called 'objects' by default.
Manager
none()
lt
Restrictions on field names
34. A convenience method for constructing an object and saving it all in one step.
when you add new apps to INSTALLED_APPS
delete()
filter chaining
create(**kwargs)
35. 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
many-to-many relationship
search
in_bulk(id_list)
36. These add custom "row-level" functionality to your objects. These act on a particular model instance.
|
Many-to-many relationship through an intermediate model
Custom model methods
latest(field_name=None)
37. 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.
values_list(*fields)
unique
in
defer(*fields)
38. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.
none()
endswith
Many-to-many relationship to self
isnull
39. 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.
Entry.objects.filter(id__gt=4)
week_day
Many-to-many relationship through an intermediate model
id field
40. 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.
reverse()
gte
==
aggregate(args - *kwargs)
41. 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.
order_by(*fields)
null
in
through argument
42. 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()
null
Many-to-many relationship through an intermediate model
filter(**kwargs)
43. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
isnull
update(**kwargs)
model
44. 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
endswith
using(alias)
primary_key
relationship spanning
45. 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.
Proxy model
get_absolute_url()
Manager methods
Q()
46. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
in
filter(**kwargs)
==
choices
47. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
OneToOneField
iendswith
reverse name
48. The default for this is the name of the child class followed by '_set'.
Meta class
reverse name
isnull
class type
49. To activate your models
get(**kwargs)
istartswith
Entry.objects.filter(pub_date__range=(start_date - end_date))
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
50. 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
clear() method
filter chaining
endswith
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