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. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12
MultipleObjectsReturned
month
iendswith
dates(field - kind - order='ASC')
2. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.
clear() method
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
year
Abstract base class
3. This query finds all entries with an id in the list [1 - 3 - 4]
Entry.objects.filter(id__in=[1 - 3 - 4])
intermediate models
iendswith
dates(field - kind - order='ASC')
4. Lookup type that returns results greater than a given value.
pk
gt
aggregate(args - *kwargs)
Restrictions on field names
5. Lookup type that returns results in a given list.
count()
primary_key
isnull
in
6. Lookup type that returns results with a case-insensitive end sequence.
Entry.objects.filter(pub_date__range=(start_date - end_date))
get(**kwargs)
iendswith
primary_key
7. This query finds all entries with an id greater than 4.
slicing
blank
Entry.objects.filter(id__gt=4)
class attributes
8. Manager method used to retrieve every object in a model.
filter(**kwargs)
all()
only(*fields)
when you add new apps to INSTALLED_APPS
9. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.
delete()
related_name
iexact
filter chaining
10. Lookup type that yields a case-insensitive match.
iexact
iterator()
exists()
null
11. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.
Entry.objects.filter(id__in=[1 - 3 - 4])
OneToOneField
exclude(**kwargs)
get(**kwargs)
12. Keyword shortcut for looking up an object by primary key.
pk
exclude(**kwargs)
iteration
contains
13. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.
update()
iregex
primary_key
Multi-table inheritance
14. 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
get_absolute_url()
filter(**kwargs)
reverse name
15. Lookup type that returns results greater than or equal to a given value.
gte
intermediate models
clear() method
iterator()
16. Conjuntion operator for Q objects.
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
&
Multi-table inheritance
values_list(*fields)
17. If this option is True - Django will store empty values as NULL in the database. Default is False.
==
delete()
OneToOneField
null
18. Returns the object matching the given lookup parameters
get(**kwargs)
extra(select=None - where=None - params=None - tables=None - order_by=None - select_params=None)
get_absolute_url()
MultipleObjectsReturned
19. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.
Model metadata
many-to-many relationship
ForeignKey
relationship spanning
20. A convenience method for constructing an object and saving it all in one step.
Manager methods
startswith
delete()
create(**kwargs)
21. 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
choices
update(**kwargs)
add()
defer(*fields)
22. Lookup type that returns results that fall into an inclusive date range.
evaluation
through argument
MultipleObjectsReturned
range
23. Lookup type that tests for inclusion in a case-sensitive fashion.
reverse()
contains
none()
delete()
24. 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
count()
Q(question__istartswith='What')
save()
25. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.
count()
exact
defer(*fields)
Q(question__startswith='Who') | ~Q(pub_date__year=2005)
26. Exception raised by get(**kwargs) if no items match the query.
DoesNotExist
Q()
get(**kwargs)
iterator()
27. These add custom "row-level" functionality to your objects. These act on a particular model instance.
iendswith
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.
search
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.
Model metadata
delete()
DoesNotExist
search
29. 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.
gt
blank
Multi-table inheritance
Q()
30. Lookup type that finds a case-sensitive regular expression match.
exclude(**kwargs)
default
regex
Meta class
31. 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
32. To activate your models
startswith
Many-to-many relationship to self
edit your settings file and change the INSTALLED_APPS setting to add the name of the module that contains your models.py.
one-to-one relationship
33. 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.
reverse()
iregex
month
range
34. 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
Meta class
count()
Field lookups
Abstract base class
35. 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.
OneToOneField
range
blank
get(**kwargs)
36. 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.
iregex
F()
all()
Many-to-many relationship through an intermediate model
37. When to run syncdb
~
Q(question__istartswith='What')
when you add new apps to INSTALLED_APPS
class type
38. This query deletes all Entry objects with a pub_date year of 2005.
Entry.objects.filter(pub_date__year=2005).delete()
reverse()
many-to-one relationship
ForeignKey
39. Returns the most recent object in the table - by date - using the field_name provided as the date field.
Multi-table inheritance
latest(field_name=None)
get(**kwargs)
Model metadata
40. 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.
&
choices
all()
Abstract base class
41. A convenience method for looking up an object with the given kwargs - creating one if necessary.
get_or_create(**kwargs)
save()
Manager
values(*fields)
42. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.
==
iregex
id field
class attributes
43. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.
using(alias)
delete()
delete()
distinct()
44. If this option is True - the field is allowed to be blank. Default is False.
unique
exact
blank
get_or_create(**kwargs)
45. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.
latest(field_name=None)
Entry.objects.filter(id__in=[1 - 3 - 4])
filter chaining
exact
46. If True - the table does not permit duplicate values for this field.
db
range
class attributes
unique
47. This gives your model metadata.
class type
Meta class
contains
gte
48. Lookup type that returns results less than a given value.
exists()
id field
lt
Custom model methods
49. 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
ManyToManyField
when you add new apps to INSTALLED_APPS
OneToOneField
class type
50. 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