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. Exception raised by get(**kwargs) if more than one item matches the query.






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






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






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






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






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






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






8. Disjunction operator for Q objects.






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


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






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






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






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






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


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






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






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






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






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






20. In some complex data-modeling situations - your models might contain a lot of fields - some of which could contain a lot of data (for example - text fields) - or require expensive processing to convert them to Python objects. If you are using the res






21. Negation operator for Q objects.






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






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






24. Lookup type for date/datetime fields that finds a 'day of the week' match.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






41. Fields are specified by these






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. If True - the table does not permit duplicate values for this field.






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






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






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






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


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






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






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