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






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






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






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






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






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






7. To activate your models






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






9. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.

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


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






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






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






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






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






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






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






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






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






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






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






21. The default for this is the name of the child class followed by '_set'.






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






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






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






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






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






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






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






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






30. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






34. Disjunction operator for Q objects.






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






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






37. Negation operator for Q objects.






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


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






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






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






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






44. Conjuntion operator for Q objects.






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






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






47. This represents a collection of objects from your database. It can have zero - one or many filters.






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






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






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