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






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






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






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






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






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






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






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






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


10. Returns the object matching the given lookup parameters






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






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






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






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






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






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


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






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






19. Fields are specified by these






20. This gives your model metadata.






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






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






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






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






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






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






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






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


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






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






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






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






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






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


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






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






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






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






39. Negation operator for Q objects.






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






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






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






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






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






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






46. Performs an SQL delete query on all rows in the QuerySet. This method is applied instantly. You cannot call this method on a QuerySet that has had a slice taken or can otherwise no longer be filtered.






47. When to run syncdb






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






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


50. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.