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 takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






2. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






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






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


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






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






13. A convenience method for constructing an object and saving it all in one step.






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






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






16. To activate your models






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






18. Lookup type that returns results less than or equal to a given value.






19. Fields are specified by these






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






21. Disjunction operator for Q objects.






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






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






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






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






26. This object allows you to compare the value of a model field with another field on the same model. Django supports the use of addition - subtraction - multiplication - division and modulo arithmetic with these objects - both with constants and with o






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






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






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






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






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






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






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






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






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






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






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






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






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






40. Negation operator for Q objects.






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


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






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






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






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






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






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






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






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






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