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. Can be used to remove all many-to-many relationships for an instance






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






3. This gives your model metadata.






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






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






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






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






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






9. Disjunction operator for Q objects.






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






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






12. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






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


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






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


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






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






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






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






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






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






22. To activate your models






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






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






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






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






27. Returns the object matching the given lookup parameters






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






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






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






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






32. Specifies the model that will be used to govern the many-to-many relationship. You can then put extra fields on the intermediate model. The intermediate model is associated with the ManyToManyField using this to point to the model that will act as an






33. Lookup type that returns results less than or equal to a given value.






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






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






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






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






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






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






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






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






42. Conjuntion operator for Q objects.






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






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






45. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.






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






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






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






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






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