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






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






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






4. Conjuntion operator for Q objects.






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






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






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






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






9. Lookup type that yields a case-insensitive match.






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






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






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






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






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






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






16. This gives your model metadata.






17. Fields are specified by these






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






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






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






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






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






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






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






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






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






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






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






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






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






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






32. This query uses an F object to increment the pingback count for every entry in the blog.


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






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






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






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






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






38. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.






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






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






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






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. Lookup type that finds a case-sensitive regular expression match.






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






45. Exception raised by get(**kwargs) if more than one item matches the query.






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






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






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






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






50. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo