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. Negation operator for Q objects.






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






3. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.






4. Disjunction operator for Q objects.






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






6. A Python "magic method" that returns a unicode "representation" of any object.






7. Fields are specified by these






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






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






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






11. Lookup type that returns results with a case-sensitive end sequence.






12. This gives your model metadata.






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






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






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






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






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






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






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






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






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






22. Returns a new QuerySet containing objects that match the given lookup parameters.






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


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






25. Lookup type for date/datetime fields that finds an exact day match.






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






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






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






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






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






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






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






33. If this option is True - Django will store empty values as NULL in the database. Default is False.






34. When to run syncdb






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






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






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






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






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






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






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






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






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


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






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






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






48. Keyword shortcut for looking up an object by primary key.






49. To activate your models






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