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. These methods are intended to do "table-wide" things.
Multi-table inheritance
Manager methods
search
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
2. 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
update(**kwargs)
none()
ManyToManyField
intermediate models
3. 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.
filter(**kwargs)
one-to-one relationship
dates(field - kind - order='ASC')
get_absolute_url()
4. Lookup type that returns results with a case-insensitive end sequence.
reverse name
iendswith
iterator()
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
5. Lookup type that returns results with a case-sensitive end sequence.
contains
delete()
Meta class
endswith
6. 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
&
model
F()
null
7. 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
8. This query finds all entries between a start date of start_date and an end date of end_date.
OneToOneField
get(**kwargs)
Entry.objects.filter(pub_date__range=(start_date - end_date))
help_text
9. A Python "magic method" that returns a unicode "representation" of any object.
__unicode__()
filter(**kwargs)
Entry.objects.filter(id__in=[1 - 3 - 4])
Multi-table inheritance
10. When to run syncdb
iexact
lt
when you add new apps to INSTALLED_APPS
Custom model methods
11. 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
intermediate models
|
evaluation
through argument
12. 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.
pickling
using(alias)
none()
null
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
exists()
save()
gte
annotate(args - *kwargs)
14. 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
15. A convenience method for constructing an object and saving it all in one step.
==
all()
search
create(**kwargs)
16. 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.
defer(*fields)
exact
ManyToManyField
Model metadata
17. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
filter(**kwargs)
Proxy model
Field lookups
Meta class
18. 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.
Entry.objects.filter(pub_date__range=(start_date - end_date))
help_text
in_bulk(id_list)
model
19. 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.
pickling
search
Multi-table inheritance
filter
20. 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.
many-to-many relationship
gte
distinct()
pickling
21. This represents a collection of objects from your database. It can have zero - one or many filters.
Model metadata
QuerySet
Restrictions on field names
gt
22. 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
reverse()
none()
Manager methods
Manager
23. 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.
db
filter
values_list(*fields)
choices
24. 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
Many-to-many relationship to self
Abstract base class
get_or_create(**kwargs)
exists()
25. This is a criterion that narrow down a QuerySet based on given parameters.
ManyToManyField
get_absolute_url()
order_by(*fields)
filter
26. 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
all()
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
gt
get_or_create(**kwargs)
27. To activate your models
only(*fields)
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
Entry.objects.filter(id__in=[1 - 3 - 4])
order_by(*fields)
28. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
get(**kwargs)
all()
default
many-to-many relationship
29. This model method is used for updating a ManyToManyField.
add()
reverse name
Field lookups
values_list(*fields)
30. A manager method which returns a single object. If there are no results that match the query - this method will raise a DoesNotExist exception. If more than one item matches this query - the method will raise MultipleObjectsReturned.
get(**kwargs)
|
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
ForeignKey
31. 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
iterator()
pickling
filter
annotate(args - *kwargs)
32. 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
regex
contains
33. If True - this field is the primary key for the model.
primary_key
in
annotate(args - *kwargs)
__unicode__()
34. 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.
unique
iregex
Multi-table inheritance
isnull
35. This field is added automatically - but this behavior can be overridden
exclude(**kwargs)
Manager methods
id field
Meta class
36. Returns the object matching the given lookup parameters
iendswith
get(**kwargs)
intermediate models
save()
37. Exception raised by get(**kwargs) if no items match the query.
DoesNotExist
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
|
regex
38. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
Q(question__istartswith='What')
exclude(**kwargs)
Restrictions on field names
39. Lookup type that returns results less than a given value.
Meta class
lt
&
delete()
40. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
class type
values(*fields)
lt
distinct()
41. a QuerySet can be sliced - using Python's array-slicing syntax.
week_day
slicing
choices
range
42. 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.
update()
choices
get(**kwargs)
startswith
43. 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.
Proxy model
unique
delete()
through argument
44. 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
exists()
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
when you add new apps to INSTALLED_APPS
annotate(args - *kwargs)
45. Keyword shortcut for looking up an object by primary key.
dates(field - kind - order='ASC')
pk
Many-to-many relationship to self
Model metadata
46. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
reverse()
blank
when you add new apps to INSTALLED_APPS
==
47. If this option is True - Django will store empty values as NULL in the database. Default is False.
in_bulk(id_list)
Many-to-many relationship to self
F()
null
48. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
isnull
relationship spanning
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
year
49. 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.
blank
db
reverse()
update()
50. 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
count()
only(*fields)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
get_absolute_url()
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