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


2. This gives your model metadata.






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






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






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






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






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






8. (1) These cannot be Python reserved words - because that would result in a Python syntax error. (2) These cannot contain more than one underscore in a row - due to the way Django's query lookup syntax works.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






27. This query deletes all Entry objects with a pub_date year of 2005.






28. Disjunction operator for Q objects.






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






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






31. Here - you can't use add - create - or assignment (i.e. - beatles.members = [...]) to create relationships. You need to specify all the detail for the relationship required by the intermediate model.






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






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


34. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






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






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






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






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






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






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






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






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






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






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






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






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






47. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo






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






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






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