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. Lookup type that returns results with a case-insensitive start sequence.






2. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






6. Returns the object matching the given lookup parameters






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






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






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






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






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






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






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






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






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






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






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






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






19. what the field _______ determines: (1) The database column type (e.g. INTEGER - VARCHAR); (2) The widget to use in Django's admin interface - if you care to use it (e.g. <input type="text"> - <select>); (3) The minimal validation requirements - used






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






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






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






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






24. Lookup type that returns results greater than or equal to a given value.






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






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






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






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


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






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






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


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






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






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






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






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






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






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






39. This gives your model metadata.






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






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






42. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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