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






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






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






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






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






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






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






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






9. Adds to each object in the QuerySet with the provided list of aggregate values (averages - sums - etc) that have been computed over the objects that are related to the objects in the QuerySet. Each argument to this is content that will be added to ea






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






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






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






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






14. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.






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






16. Conjuntion operator for Q objects.






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






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






19. 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()






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






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






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






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






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






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






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






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






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






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






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






31. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






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






44. This query uses an F object to increment the pingback count for every entry in the blog.

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


45. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






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






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


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






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






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