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


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






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






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






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






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






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






8. Returns the object matching the given lookup parameters






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






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






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






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






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






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






15. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo






16. To activate your models






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






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






19. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.






20. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






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






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






34. This gives your model metadata.






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






36. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.






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






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






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






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






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






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






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






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






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






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






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






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






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






50. Can be used to remove all many-to-many relationships for an instance