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. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
==
Abstract base class
exclude(**kwargs)
null
2. Lookup type that returns results greater than a given value.
gt
Model metadata
annotate(args - *kwargs)
iregex
3. 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
4. Lookup type that finds a case-insensitive regular expression match.
in
lt
Model metadata
iregex
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
Q()
lte
lt
F()
6. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
ordered
search
iendswith
defer(*fields)
7. 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.
filter
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
relationship spanning
many-to-one relationship
8. 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.
in_bulk(id_list)
select_related()
update(**kwargs)
Multi-table inheritance
9. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.
regex
add()
filter chaining
pickling
10. 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.
distinct()
add()
iexact
values_list(*fields)
11. 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
Field lookups
day
none()
~
12. 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
13. 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.
using(alias)
clear() method
add()
get_or_create(**kwargs)
14. The database that will be used if this query is executed now
db
iteration
delete()
day
15. If this option is True - the field is allowed to be blank. Default is False.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
blank
in_bulk(id_list)
exists()
16. 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.
blank
related_name
search
startswith
17. Lookup type that returns results less than or equal to a given value.
when you add new apps to INSTALLED_APPS
lte
null
search
18. 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
range
Abstract base class
latest(field_name=None)
related_name
19. 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.
save()
MultipleObjectsReturned
Proxy model
Many-to-many relationship through an intermediate model
20. Disjunction operator for Q objects.
Manager methods
iendswith
|
create(**kwargs)
21. Lookup type that returns results greater than or equal to a given value.
gte
month
choices
dates(field - kind - order='ASC')
22. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
get(**kwargs)
MultipleObjectsReturned
evaluation
year
23. 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.
one-to-one relationship
default
order_by(*fields)
null
24. This query finds all entries between a start date of start_date and an end date of end_date.
unique
create(**kwargs)
filter(**kwargs)
Entry.objects.filter(pub_date__range=(start_date - end_date))
25. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
exclude(**kwargs)
Manager methods
select_related()
month
26. A convenience method for constructing an object and saving it all in one step.
in
none()
create(**kwargs)
values_list(*fields)
27. If True - the table does not permit duplicate values for this field.
model
Manager
latest(field_name=None)
unique
28. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.
choices
get(**kwargs)
OneToOneField
class attributes
29. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
intermediate models
F()
month
help_text
30. Keyword shortcut for looking up an object by primary key.
istartswith
search
class attributes
pk
31. 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)
blank
contains
Model metadata
iendswith
32. Negation operator for Q objects.
distinct()
~
count()
endswith
33. 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
exists()
iendswith
regex
34. When to run syncdb
==
get_absolute_url()
iendswith
when you add new apps to INSTALLED_APPS
35. 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.
when you add new apps to INSTALLED_APPS
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
many-to-many relationship
ManyToManyField
36. 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.
Q()
clear() method
week_day
class attributes
37. 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
38. 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.
dates(field - kind - order='ASC')
update()
exact
class type
39. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
aggregate(args - *kwargs)
filter(**kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Many-to-many relationship to self
40. 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
latest(field_name=None)
class type
contains
ManyToManyField
41. 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.
filter(**kwargs)
using(alias)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
evaluation
42. 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)
id field
through argument
__unicode__()
43. This query deletes all Entry objects with a pub_date year of 2005.
regex
in_bulk(id_list)
all()
Entry.objects.filter(pub_date__year=2005).delete()
44. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
class type
latest(field_name=None)
filter
isnull
45. 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.
get(**kwargs)
Entry.objects.filter(id__in=[1 - 3 - 4])
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
ForeignKey
46. Returns a new QuerySet containing objects that match the given lookup parameters.
update()
help_text
filter(**kwargs)
null
47. 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.
Custom model methods
update()
Many-to-many relationship to self
get(**kwargs)
48. 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
iregex
ordered
~
iterator()
49. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
exists()
many-to-one relationship
Field lookups
db
50. This field is added automatically - but this behavior can be overridden
unique
lt
update()
id field
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