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.
default
select_related()
get(**kwargs)
get_absolute_url()
2. Negation operator for Q objects.
using(alias)
year
~
in
3. 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
week_day
values_list(*fields)
intermediate models
startswith
4. Exception raised by get(**kwargs) if more than one item matches the query.
MultipleObjectsReturned
OneToOneField
many-to-one relationship
in_bulk(id_list)
5. Returns the most recent object in the table - by date - using the field_name provided as the date field.
Manager
latest(field_name=None)
annotate(args - *kwargs)
Restrictions on field names
6. 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)
exclude(**kwargs)
Model metadata
Meta class
add()
7. Used to get a QuerySet for a model. This is called 'objects' by default.
only(*fields)
Abstract base class
Many-to-many relationship through an intermediate model
Manager
8. Lookup type that tests for inclusion in a case-sensitive fashion.
delete()
unique
contains
Q()
9. 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.
ManyToManyField
Meta class
month
QuerySet
10. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.
month
values(*fields)
week_day
ordered
11. Conjuntion operator for Q objects.
&
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
pk
12. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
gte
through argument
Restrictions on field names
13. 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.
==
aggregate(args - *kwargs)
Entry.objects.filter(pub_date__year=2005).delete()
delete()
14. (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.
Restrictions on field names
pickling
exclude(**kwargs)
evaluation
15. 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)
filter(**kwargs)
update(**kwargs)
Proxy model
16. 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
~
regex
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
17. A QuerySet is iterable - and it executes its database query the first time you iterate over it.
regex
iteration
default
model
18. When to run syncdb
when you add new apps to INSTALLED_APPS
gt
count()
lt
19. This method immediately deletes the object and has no return value.
delete()
pk
pickling
reverse name
20. 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()
Many-to-many relationship through an intermediate model
Multi-table inheritance
choices tuple
21. 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.
delete()
using(alias)
latest(field_name=None)
defer(*fields)
22. In some complex data-modeling situations - your models might contain a lot of fields - some of which could contain a lot of data (for example - text fields) - or require expensive processing to convert them to Python objects. If you are using the res
month
isnull
get(**kwargs)
defer(*fields)
23. 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.
through argument
get(**kwargs)
using(alias)
all()
24. By default - results returned by a QuerySet are ordered by the ordering tuple given by the ordering option in the model's Meta. You can override this on a per-QuerySet basis by using the this method.
intermediate models
filter
order_by(*fields)
Entry.objects.filter(pub_date__year=2005).delete()
25. This model method saves a model instance to the database. This method has no return value.
save()
isnull
clear() method
update(**kwargs)
26. Lookup type that finds a case-sensitive regular expression match.
regex
pk
relationship spanning
Many-to-many relationship to self
27. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.
==
iregex
count()
one-to-one relationship
28. 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.
defer(*fields)
search
many-to-one relationship
regex
29. 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.
many-to-one relationship
range
filter
save()
30. 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
gte
get(**kwargs)
latest(field_name=None)
Abstract base class
31. 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.
pickling
aggregate(args - *kwargs)
~
range
32. 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
33. Returns the object matching the given lookup parameters
Field lookups
Entry.objects.filter(pub_date__range=(start_date - end_date))
get(**kwargs)
annotate(args - *kwargs)
34. The database that will be used if this query is executed now
save()
only(*fields)
db
&
35. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.
lt
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
isnull
pickling
36. A convenience method for looking up an object with the given kwargs - creating one if necessary.
all()
filter(**kwargs)
get_or_create(**kwargs)
Manager
37. 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
Manager methods
iterator()
defer(*fields)
Abstract base class
38. 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()
dates(field - kind - order='ASC')
filter(**kwargs)
all()
39. 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
Q(question__istartswith='What')
pickling
all()
iterator()
40. 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.
Entry.objects.filter(id__in=[1 - 3 - 4])
distinct()
pickling
unique
41. 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.
Entry.objects.filter(id__in=[1 - 3 - 4])
order_by(*fields)
exists()
values_list(*fields)
42. 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
class type
get(**kwargs)
pk
~
43. If True - this field is the primary key for the model.
create(**kwargs)
primary_key
get(**kwargs)
Proxy model
44. 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
45. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
lt
related_name
many-to-many relationship
==
46. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
isnull
exclude(**kwargs)
slicing
filter(**kwargs)
47. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .
clear() method
get_absolute_url()
Field lookups
~
48. 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
49. Lookup type that returns results greater than a given value.
using(alias)
Q(question__istartswith='What')
gt
db
50. Lookup type that returns results greater than or equal to a given value.
unique
when you add new apps to INSTALLED_APPS
gte
only(*fields)
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