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. If True - this field is the primary key for the model.






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






3. To activate your models






4. Fields are specified by these






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






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






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






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


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






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






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






12. Performs an SQL delete query on all rows in the QuerySet. This method is applied instantly. You cannot call this method on a QuerySet that has had a slice taken or can otherwise no longer be filtered.






13. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






35. The default for this is the name of the child class followed by '_set'.






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






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






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






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






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






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






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






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


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






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






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






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






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






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