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






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


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






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






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






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

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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






8. Negation operator for Q objects.






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






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






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






12. Disjunction operator for Q objects.






13. This gives your model metadata.






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






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


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






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






18. Conjuntion operator for Q objects.






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






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






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






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






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






24. Returns the object matching the given lookup parameters






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






26. A convenience method for constructing an object and saving it all in one step.






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






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






29. Lookup type that returns results less than or equal to a given value.






30. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






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. This query deletes all Entry objects with a pub_date year of 2005.






33. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.






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






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






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






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






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






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






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






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






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






43. Fields are specified by these






44. Lookup type that returns results with a case-sensitive end sequence.






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






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






47. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.






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






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






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