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. If True - this field is the primary key for the model.






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






3. Negation operator for Q objects.






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






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






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






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






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






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






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






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






12. Disjunction operator for Q objects.






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






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






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






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






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






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






19. Conjuntion operator for Q objects.






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






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






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






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






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






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






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


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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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