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






2. This query finds all entries with an id in the list [1 - 3 - 4]






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






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






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






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






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






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






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






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






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






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






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






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






16. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.






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






18. If this option is True - Django will store empty values as NULL in the database. Default is False.






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






20. When to run syncdb






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






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






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






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






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






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






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






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






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






30. Returns the object matching the given lookup parameters






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






32. This query finds all entries with an id greater than 4.






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






34. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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