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






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






3. A convenience method for looking up an object with the given kwargs - creating one if necessary.






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






5. Returns a dictionary of aggregate values (averages - sums - etc) calculated over the QuerySet. Each argument to this method specifies a value that will be included in the dictionary that is returned.






6. Adds to each object in the QuerySet with the provided list of aggregate values (averages - sums - etc) that have been computed over the objects that are related to the objects in the QuerySet. Each argument to this is content that will be added to ea






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






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






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






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






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






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






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


14. Conjuntion operator for Q objects.






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






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






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






18. To activate your models






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






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. Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results.






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






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






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






46. Disjunction operator for Q objects.






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






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






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






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