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. Keyword shortcut for looking up an object by primary key.






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






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






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






5. To activate your models






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






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






8. If this option is True - the field is allowed to be blank. Default is False.






9. Exception raised by get(**kwargs) if no items match the query.






10. Used to get a QuerySet for a model. This is called 'objects' by default.






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






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






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






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






15. Lookup type that tests for inclusion in a case-sensitive fashion.






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






17. Disjunction operator for Q objects.






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






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






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






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






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






23. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






24. Lookup type that returns results with a case-insensitive end sequence.






25. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.






26. This field is added automatically - but this behavior can be overridden






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






28. Negation operator for Q objects.






29. Lookup type for date/datetime fields that finds an exact day match.






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






31. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.






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






33. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.


34. This query finds all entries with an id in the list [1 - 3 - 4]






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






36. The database that will be used if this query is executed now






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






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






39. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.


40. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.






41. This is a criterion that narrow down a QuerySet based on given parameters.






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






43. Lookup type that returns results greater than a given value.






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






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






46. When to run syncdb






47. Lookup type that returns results in a given list.






48. Lookup type that returns results greater than or equal to a given value.






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






50. 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)