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






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






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






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






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






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






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






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






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






10. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.


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






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






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






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






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






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






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






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






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






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






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






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






23. Negation operator for Q objects.






24. When to run syncdb






25. Defines a many-to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model.






26. These add custom "row-level" functionality to your objects. These act on a particular model instance.






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






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






29. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.






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






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






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






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






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






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






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






37. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.


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






39. Disjunction operator for Q objects.






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






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






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






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






44. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()






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






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






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






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






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






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