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. This represents a collection of objects from your database. It can have zero - one or many filters.






2. Returns the object matching the given lookup parameters






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


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






5. Lookup type that finds a case-sensitive regular expression match.






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






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






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






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






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






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






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






13. Keyword shortcut for looking up an object by primary key.






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






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






16. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()






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






18. Negation operator for Q objects.






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






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






21. Specifies the model that will be used to govern the many-to-many relationship. You can then put extra fields on the intermediate model. The intermediate model is associated with the ManyToManyField using this to point to the model that will act as an






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






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






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






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






26. A convenience method for looking up an object with the given kwargs - creating one if necessary.






27. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.






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






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






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






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






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






33. When to run syncdb






34. If True - this field is the primary key for the model.






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






36. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.






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






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






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






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






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






42. Lookup type for date/datetime fields that finds a 'day of the week' match.






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






44. Disjunction operator for Q objects.






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






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






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






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


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






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