Test your basic knowledge |

Django Queryset

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 the object matching the given lookup parameters






2. These add custom "row-level" functionality to your objects. These act on a particular model instance.






3. 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.






4. 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.






5. When to run syncdb






6. Lookup type that returns results that fall into an inclusive date range.






7. This query deletes all Entry objects with a pub_date year of 2005.






8. 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.






9. This gives your model metadata.






10. 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.






11. 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.






12. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12






13. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






14. The default for this is the name of the child class followed by '_set'.






15. 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.






16. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.






17. Lookup type that yields a case-insensitive match.






18. 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






19. 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






20. 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






21. 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


22. 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.






23. 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






24. These methods are intended to do "table-wide" things.






25. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.






26. 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.






27. Fields are specified by these






28. a QuerySet can be sliced - using Python's array-slicing syntax.






29. (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.






30. 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






31. Lookup type that returns results with a case-sensitive start sequence.






32. This model method is used for updating a ManyToManyField.






33. Lookup type that returns results less than a given value.






34. Can be used to remove all many-to-many relationships for an instance






35. 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


36. 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






37. 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.






38. Lookup type that finds a case-insensitive regular expression match.






39. 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






40. 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






41. Defines a many-to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model.






42. 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.






43. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.






44. To activate your models






45. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






46. Returns a new QuerySet containing objects that match the given lookup parameters.






47. 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






48. 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.






49. If this option is True - Django will store empty values as NULL in the database. Default is False.






50. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.