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






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






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






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






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






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






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






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






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






10. Conjuntion operator for Q objects.






11. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.






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






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. Disjunction operator for Q objects.






15. Evaluates the QuerySet (by performing the query) and returns an iterator over the results. A QuerySet typically caches its results internally so that repeated evaluations do not result in additional queries; this method will instead read results dire






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






31. To activate your models






32. Negation operator for Q objects.






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






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






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






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






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






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






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






40. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F






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






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






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






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






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

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


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






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






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






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






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