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 is a criterion that narrow down a QuerySet based on given parameters.






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






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






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






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






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






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


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






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






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






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






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






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






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


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






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






17. The database that will be used if this query is executed now






18. This query finds all entries with an id greater than 4.






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






20. Fields are specified by these






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






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






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 greater than or equal to a given value.






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






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






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






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






29. Negation operator for Q objects.






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






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






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






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






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






35. This tells Django how to calculate the URL for an object. Django uses this in its admin interface - and any time it needs to figure out a URL for an object.






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






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






38. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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






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






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






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






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






44. Returns the object matching the given lookup parameters






45. When to run syncdb






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






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


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






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






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