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. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
class type
distinct()
day
update()
2. If this option is True - Django will store empty values as NULL in the database. Default is False.
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
isnull
null
choices tuple
3. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.
filter(**kwargs)
month
gte
contains
4. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
ManyToManyField
year
isnull
Entry.objects.filter(pub_date__range=(start_date - end_date))
5. 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.
Proxy model
==
using(alias)
lt
6. 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.
aggregate(args - *kwargs)
help_text
Multi-table inheritance
create(**kwargs)
7. 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
Abstract base class
select_related()
count()
F()
8. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
==
Manager methods
none()
related_name
9. This query finds all entries with an id greater than 4.
default
Entry.objects.filter(id__gt=4)
Entry.objects.filter(id__in=[1 - 3 - 4])
relationship spanning
10. Disjunction operator for Q objects.
count()
intermediate models
|
month
11. 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.
filter(**kwargs)
Multi-table inheritance
select_related()
blank
12. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
save()
contains
many-to-many relationship
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
13. A convenience method for constructing an object and saving it all in one step.
clear() method
save()
dates(field - kind - order='ASC')
create(**kwargs)
14. 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.
latest(field_name=None)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
in_bulk(id_list)
select_related()
15. 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.
update(**kwargs)
ForeignKey
DoesNotExist
pickling
16. This model method is used for updating a ManyToManyField.
get(**kwargs)
dates(field - kind - order='ASC')
add()
regex
17. 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
choices
model
annotate(args - *kwargs)
Custom model methods
18. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
values_list(*fields)
==
iendswith
|
19. 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.
iterator()
pk
endswith
get(**kwargs)
20. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
year
default
add()
QuerySet
21. Lookup type that finds a case-sensitive regular expression match.
iterator()
istartswith
regex
null
22. A convenience method for looking up an object with the given kwargs - creating one if necessary.
update()
aggregate(args - *kwargs)
all()
get_or_create(**kwargs)
23. A Python "magic method" that returns a unicode "representation" of any object.
latest(field_name=None)
__unicode__()
Model metadata
Entry.objects.filter(pub_date__year=2007).update(headline='Everything is the same')
24. Conjuntion operator for Q objects.
iteration
only(*fields)
iexact
&
25. This query finds all entries between a start date of start_date and an end date of end_date.
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
count()
Entry.objects.filter(pub_date__range=(start_date - end_date))
Meta class
26. 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
27. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
update(**kwargs)
month
regex
gt
28. 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.
delete()
Entry.objects.filter(pub_date__range=(start_date - end_date))
OneToOneField
iregex
29. These add custom "row-level" functionality to your objects. These act on a particular model instance.
Entry.objects.filter(pub_date__year=2005).delete()
Q(question__istartswith='What')
Custom model methods
filter chaining
30. Lookup type that tests for inclusion in a case-sensitive fashion.
F()
MultipleObjectsReturned
Entry.objects.filter(pub_date__range=(start_date - end_date))
contains
31. These methods are intended to do "table-wide" things.
Manager methods
range
class attributes
get_absolute_url()
32. Lookup type that returns results less than or equal to a given value.
lte
MultipleObjectsReturned
choices tuple
Custom model methods
33. To activate your models
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
QuerySet
search
add()
34. 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)
|
Manager
filter(**kwargs)
35. a QuerySet can be sliced - using Python's array-slicing syntax.
slicing
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
==
OneToOneField
36. If this option is True - the field is allowed to be blank. Default is False.
iregex
ManyToManyField
blank
F()
37. This field is added automatically - but this behavior can be overridden
id field
Restrictions on field names
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
through argument
38. 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)
none()
filter(**kwargs)
month
Model metadata
39. 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.
iendswith
choices
unique
when you add new apps to INSTALLED_APPS
40. 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.
|
latest(field_name=None)
help_text
range
41. Can be used to remove all many-to-many relationships for an instance
dates(field - kind - order='ASC')
contains
exact
clear() method
42. 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
43. 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
all()
Field lookups
intermediate models
iterator()
44. Fields are specified by these
values_list(*fields)
when you add new apps to INSTALLED_APPS
blank
class attributes
45. 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.
day
Many-to-many relationship through an intermediate model
values_list(*fields)
ForeignKey
46. 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
defer(*fields)
create(**kwargs)
related_name
none()
47. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.
model
distinct()
related_name
|
48. Returns a new QuerySet containing objects that match the given lookup parameters.
update()
Q()
exact
filter(**kwargs)
49. Lookup type that finds a case-insensitive regular expression match.
choices tuple
many-to-many relationship
lte
iregex
50. Lookup type that returns results greater than or equal to a given value.
class attributes
range
Q()
gte
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