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 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
all()
only(*fields)
F()
month
2. 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()
month
relationship spanning
3. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
ManyToManyField
class attributes
Entry.objects.filter(pub_date__year=2005).delete()
filter(**kwargs)
4. Lookup type that finds a case-sensitive regular expression match.
__unicode__()
regex
Field lookups
many-to-many relationship
5. 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
intermediate models
contains
aggregate(args - *kwargs)
regex
6. 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
filter(**kwargs)
endswith
clear() method
update(**kwargs)
7. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
Multi-table inheritance
ForeignKey
Model metadata
8. Returns the object matching the given lookup parameters
get(**kwargs)
in
Multi-table inheritance
unique
9. Exception raised by get(**kwargs) if more than one item matches the query.
blank
MultipleObjectsReturned
Manager
==
10. 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
11. 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
values_list(*fields)
exact
Restrictions on field names
12. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
in
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
Entry.objects.filter(pub_date__year=2005).delete()
month
13. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
values(*fields)
aggregate(args - *kwargs)
Q(question__istartswith='What')
get(**kwargs)
14. 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.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
pickling
evaluation
reverse name
15. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
isnull
==
pickling
many-to-many relationship
16. 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
Custom model methods
get(**kwargs)
get_absolute_url()
only(*fields)
17. If this option is True - the field is allowed to be blank. Default is False.
blank
Abstract base class
get(**kwargs)
Restrictions on field names
18. 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
week_day
exists()
count()
month
19. Exception raised by get(**kwargs) if no items match the query.
ForeignKey
|
class attributes
DoesNotExist
20. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.
aggregate(args - *kwargs)
only(*fields)
relationship spanning
Multi-table inheritance
21. Lookup type that returns results less than or equal to a given value.
choices
iendswith
lte
aggregate(args - *kwargs)
22. Lookup type that returns results with a case-sensitive start sequence.
startswith
exists()
evaluation
select_related()
23. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.
reverse name
using(alias)
exclude(**kwargs)
ordered
24. Negation operator for Q objects.
many-to-one relationship
~
related_name
iteration
25. 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
26. 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.
one-to-one relationship
exists()
month
aggregate(args - *kwargs)
27. A Python "magic method" that returns a unicode "representation" of any object.
__unicode__()
day
ForeignKey
MultipleObjectsReturned
28. Lookup type that returns results that fall into an inclusive date range.
startswith
Manager methods
range
F()
29. Keyword shortcut for looking up an object by primary key.
OneToOneField
pk
many-to-one relationship
choices
30. 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.
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
filter chaining
iteration
latest(field_name=None)
31. 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
pk
gte
all()
values(*fields)
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.
|
search
filter chaining
annotate(args - *kwargs)
33. 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.
model
DoesNotExist
through argument
Q()
34. This gives your model metadata.
Manager
DoesNotExist
OneToOneField
Meta class
35. 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
Abstract base class
search
one-to-one relationship
contains
36. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.
add()
choices tuple
Q(question__istartswith='What')
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
37. 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)
Model metadata
class type
exists()
Q(question__istartswith='What')
38. Lookup type that finds a case-insensitive regular expression match.
Manager
range
iregex
class type
39. Returns the most recent object in the table - by date - using the field_name provided as the date field.
latest(field_name=None)
using(alias)
startswith
add()
40. If True - this field is the primary key for the model.
iendswith
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
primary_key
add()
41. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
startswith
save()
DoesNotExist
42. Used to get a QuerySet for a model. This is called 'objects' by default.
through argument
Manager
latest(field_name=None)
DoesNotExist
43. 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.
dates(field - kind - order='ASC')
ForeignKey
annotate(args - *kwargs)
values_list(*fields)
44. Lookup type that returns results with a case-insensitive start sequence.
model
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
defer(*fields)
istartswith
45. (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.
class type
Restrictions on field names
save()
istartswith
46. The default for this is the name of the child class followed by '_set'.
Q(question__istartswith='What')
reverse name
range
ManyToManyField
47. When to run syncdb
one-to-one relationship
none()
when you add new apps to INSTALLED_APPS
many-to-many relationship
48. To activate your models
Custom model methods
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
in
update(**kwargs)
49. 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
add()
Entry.objects.filter(id__gt=4)
defer(*fields)
50. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
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