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. This query finds all entries with an id in the list [1 - 3 - 4]






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






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






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






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






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






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






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






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


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






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


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






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






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






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






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






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






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






19. Returns a QuerySet that will automatically "follow" foreign-key relationships - selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later u






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






22. Exception raised by get(**kwargs) if more than one item matches the query.






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






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






25. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






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






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






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






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






34. When to run syncdb






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






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






37. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






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






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






48. Returns the object matching the given lookup parameters






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






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