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






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






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






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






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






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






8. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.






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






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






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






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






13. Lookup type that returns results with a case-sensitive end sequence.






14. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.






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






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






17. If this option is True - the field is allowed to be blank. Default is False.






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






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






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






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






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






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






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






25. Negation operator for Q objects.






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






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






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






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






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






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






32. Lookup type for date/datetime fields that finds an exact day match.






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






34. Lookup type that returns results greater than or equal to a given value.






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






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






37. When to run syncdb






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






39. These methods are intended to do "table-wide" things.






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






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






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






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






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






45. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.






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






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






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






49. Fields are specified by these






50. Returns the object matching the given lookup parameters