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. a QuerySet can be sliced - using Python's array-slicing syntax.






2. When to run syncdb






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






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






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. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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






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






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






10. Conjuntion operator for Q objects.






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






12. Returns the object matching the given lookup parameters






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






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






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






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






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






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






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






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






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






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






23. This gives your model metadata.






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






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






26. This method immediately deletes the object and has no return value.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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 returns results with a case-sensitive end sequence.






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






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






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






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






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






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






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