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






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






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


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






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






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






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






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






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






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






11. To activate your models






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






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






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






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






16. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.

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


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






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






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






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


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






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






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






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






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






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






27. Returns the object matching the given lookup parameters






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






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






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






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






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






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






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






35. This query finds all entries with an id greater than 4.






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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