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






2. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo






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






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






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






6. Returns True if the QuerySet contains any results - and False if not. This tries to perform the query in the simplest and fastest way possible - but it does execute nearly the same query. This means that calling this method on a queryset is faster th






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






8. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.






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






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






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






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






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


14. Defines a many-to-one relationship. ou use it just like any other Field type: by including it as a class attribute of your model.






15. This gives your model metadata.






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






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






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






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






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






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


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






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






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






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


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






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






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






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






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






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






32. These methods are intended to do "table-wide" things.






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






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






35. Negation operator for Q objects.






36. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.






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






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






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






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






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






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






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






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






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






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






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






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






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






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