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. Lookup type that returns results greater than a given value.






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






3. Returns a QuerySet that will automatically "follow" foreign-key relationships - selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later u






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






5. Fields are specified by these






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






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






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


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






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






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






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






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






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






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






16. When to run syncdb






17. This query deletes all Entry objects with a pub_date year of 2005.






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






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






20. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.






21. Lookup type that returns results in a given list.






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






23. A Python "magic method" that returns a unicode "representation" of any object.






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






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






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






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






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






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






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






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






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






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






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






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






36. Negation operator for Q objects.






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






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






39. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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