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. The default for this is the name of the child class followed by '_set'.






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






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






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






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






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






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






8. When to run syncdb






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






28. Used to get a QuerySet for a model. This is called 'objects' by default.






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






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






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






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


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






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






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






36. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.






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






38. Negation operator for Q objects.






39. Lookup type that returns results with a case-sensitive start sequence.






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






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






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






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






44. Conjuntion operator for Q objects.






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






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






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






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






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


50. Lookup type that returns results with a case-insensitive start sequence.