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. Exception raised by get(**kwargs) if no items match the query.






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






3. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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






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






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






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






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






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






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






11. When to run syncdb






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






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






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






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






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






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






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






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






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






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






22. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






34. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.






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






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






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






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






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






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






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






42. In some complex data-modeling situations - your models might contain a lot of fields - some of which could contain a lot of data (for example - text fields) - or require expensive processing to convert them to Python objects. If you are using the res






43. This gives your model metadata.






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






45. Negation operator for Q objects.






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






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






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






49. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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