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. These methods are intended to do "table-wide" things.






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






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






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


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






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






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






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






9. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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






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






12. To activate your models






13. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.






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






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






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






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






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






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






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






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






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






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






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


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






26. This query deletes all Entry objects with a pub_date year of 2005.






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






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






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






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






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


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






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






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






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






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






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






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






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






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. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.






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






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






44. Negation operator for Q objects.






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






46. This gives your model metadata.






47. Here - you can't use add - create - or assignment (i.e. - beatles.members = [...]) to create relationships. You need to specify all the detail for the relationship required by the intermediate model.






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






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






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