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. Can be used to remove all many-to-many relationships for an instance






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






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






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






5. Extra text to be displayed under the field on the object's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form.






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






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






8. Manager method used to retrieve every object in a model.






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






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






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






12. Returns the object matching the given lookup parameters






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






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






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






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






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






18. Fields are specified by these






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






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






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






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. These methods are intended to do "table-wide" things.






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






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






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






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






28. This gives your model metadata.






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






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






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






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






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






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






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






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






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






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






39. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.






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






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






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






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






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






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






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






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






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






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






50. Conjuntion operator for Q objects.