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-sensitive end sequence.






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. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.






4. When to run syncdb






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






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






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






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






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. These add custom "row-level" functionality to your objects. These act on a particular model instance.






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


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






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






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






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. If this option is True - Django will store empty values as NULL in the database. Default is False.






17. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






32. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.






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






34. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






42. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.






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






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. A Python "magic method" that returns a unicode "representation" of any object.






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






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






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






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






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