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. Exception raised by get(**kwargs) if no items match the query.






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






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






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






5. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






6. Disjunction operator for Q objects.






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






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






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






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






11. To activate your models






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






13. Lookup type that returns results with a case-insensitive start sequence.






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






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






16. Conjuntion operator for Q objects.






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






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






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






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






21. A Python "magic method" that returns a unicode "representation" of any object.






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






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






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






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






26. This represents a collection of objects from your database. It can have zero - one or many filters.






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






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






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






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






31. This model method saves a model instance to the database. This method has no return value.






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






49. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.






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