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. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.






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






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






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






5. Returns a dictionary of aggregate values (averages - sums - etc) calculated over the QuerySet. Each argument to this method specifies a value that will be included in the dictionary that is returned.






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






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






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

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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






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






11. Disjunction operator for Q objects.






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






13. Fields are specified by these






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






15. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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






17. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






34. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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






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






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






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






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






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






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






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






43. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo






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






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






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






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






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






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






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