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






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






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. This query finds all entries with an id greater than 4.






5. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






26. Conjuntion operator for Q objects.






27. Lookup type that returns results in a given list.






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






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






30. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






48. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.






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






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