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. A Python "magic method" that returns a unicode "representation" of any object.






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






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






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






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






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






7. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.






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






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






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






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






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






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






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






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






16. Exception raised by get(**kwargs) if no items match the query.






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






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






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






20. The database that will be used if this query is executed now






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






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






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






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






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






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






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






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






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






30. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.

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


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






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






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






34. To activate your models






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






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






37. Defined by a OneToOneField. 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 in a given list.






39. Negation operator for Q objects.






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






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






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






44. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






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






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






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






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






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






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