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. A convenience method for constructing an object and saving it all in one step.






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






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






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






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






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






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






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 finds a case-insensitive regular expression match.






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






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






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






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






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






15. This gives your model metadata.






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






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






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






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






20. If you pickle a QuerySet - this will force all the results to be loaded into memory prior to pickling. When you unpickle a QuerySet - it contains the results at the moment it was pickled - rather than the results that are currently in the database.






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






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






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






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. Lookup type for date/datetime fields that finds a 'day of the week' match.






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






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






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






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


30. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.






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






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


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






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






35. By default - results returned by a QuerySet are ordered by the ordering tuple given by the ordering option in the model's Meta. You can override this on a per-QuerySet basis by using the this method.






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






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






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






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






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






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






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


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






44. To activate your models






45. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.






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






47. A manager method which returns a single object. If there are no results that match the query - this method will raise a DoesNotExist exception. If more than one item matches this query - the method will raise MultipleObjectsReturned.






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


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






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