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 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()
Multi-table inheritance
filter(**kwargs)
one-to-one relationship
2. 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
one-to-one relationship
update(**kwargs)
Manager
help_text
3. This query finds all entries with an id greater than 4.
Entry.objects.filter(id__gt=4)
evaluation
==
Manager methods
4. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
reverse name
month
update()
values(*fields)
5. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
values_list(*fields)
count()
class attributes
get_absolute_url()
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
many-to-one relationship
none()
Field lookups
order_by(*fields)
7. Lookup type that returns results with a case-sensitive start sequence.
startswith
annotate(args - *kwargs)
values_list(*fields)
many-to-many 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)
values(*fields)
ForeignKey
Custom model methods
9. Used to get a QuerySet for a model. This is called 'objects' by default.
Manager
gte
pickling
range
10. Lookup type that tests for inclusion in a case-sensitive fashion.
contains
one-to-one relationship
help_text
db
11. 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.
isnull
select_related()
ManyToManyField
many-to-one relationship
12. 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
regex
Many-to-many relationship to self
Entry.objects.filter(id__gt=4)
annotate(args - *kwargs)
13. If this option is True - the field is allowed to be blank. Default is False.
blank
order_by(*fields)
select_related()
endswith
14. 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.
|
default
week_day
iteration
15. 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.
when you add new apps to INSTALLED_APPS
delete()
update(**kwargs)
regex
16. Lookup type that yields a case-insensitive match.
OneToOneField
iexact
startswith
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
17. 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
Meta class
count()
Restrictions on field names
relationship spanning
18. 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
ForeignKey
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
iterator()
model
19. If this option is True - Django will store empty values as NULL in the database. Default is False.
year
null
latest(field_name=None)
endswith
20. This query deletes all Entry objects with a pub_date year of 2005.
reverse()
Entry.objects.filter(pub_date__year=2005).delete()
OneToOneField
delete()
21. 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.
iregex
Multi-table inheritance
many-to-one relationship
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
22. 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
order_by(*fields)
Model metadata
__unicode__()
23. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model
count()
related_name
Proxy model
MultipleObjectsReturned
24. 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()
distinct()
evaluation
all()
intermediate models
25. 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
26. 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))
month
&
distinct()
27. These add custom "row-level" functionality to your objects. These act on a particular model instance.
id field
primary_key
Custom model methods
get(**kwargs)
28. This gives your model metadata.
null
istartswith
delete()
Meta class
29. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
year
ForeignKey
distinct()
Entry.objects.filter(id__gt=4)
30. A convenience method for constructing an object and saving it all in one step.
F()
create(**kwargs)
get(**kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
31. Lookup type that returns results less than or equal to a given value.
&
MultipleObjectsReturned
lte
delete()
32. Returns a QuerySet that will automatically "follow" foreign-key relationships - selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later u
save()
select_related()
latest(field_name=None)
db
33. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
day
Entry.objects.filter(pub_date__year=2005).delete()
one-to-one relationship
34. Lookup type for date/datetime fields that finds an exact day match.
filter chaining
iendswith
day
ManyToManyField
35. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
related_name
Custom model methods
Manager methods
defer(*fields)
36. 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
Many-to-many relationship through an intermediate model
when you add new apps to INSTALLED_APPS
save()
37. Lookup type that returns results in a given list.
annotate(args - *kwargs)
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
through argument
in
38. Returns the object matching the given lookup parameters
get(**kwargs)
year
Manager methods
choices tuple
39. If True - this field is the primary key for the model.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
blank
primary_key
&
40. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
Q()
get(**kwargs)
isnull
Field lookups
41. Lookup type that finds a case-sensitive regular expression match.
regex
add()
intermediate models
iexact
42. Extra text to be displayed under the field on the object's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form.
__unicode__()
help_text
ForeignKey
|
43. 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
aggregate(args - *kwargs)
none()
delete()
exists()
44. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
range
iregex
Q()
exclude(**kwargs)
45. 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.
id field
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
reverse()
through argument
46. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
iexact
filter(**kwargs)
47. 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.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
choices tuple
Entry.objects.filter(pub_date__year=2005).delete()
Restrictions on field names
48. 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.
in
__unicode__()
values_list(*fields)
clear() method
49. This method immediately deletes the object and has no return value.
__unicode__()
in
delete()
in_bulk(id_list)
50. Disjunction operator for Q objects.
reverse name
|
Q()
evaluation
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