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. Disjunction operator for Q objects.






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






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






4. To activate your models






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






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






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






8. This query finds all entries between a start date of start_date and an end date of end_date.






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






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






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






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






13. This gives your model metadata.






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






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






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






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






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


19. If True - the table does not permit duplicate values for this field.






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






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






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


23. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


40. Fields are specified by these






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






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






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






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






45. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






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