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






2. This gives your model metadata.






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






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






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






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






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






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






9. This method returns tuples of values when iterated over. Each tuple contains the value from the respective field passed into the call to this method -- so the first item is the first field - etc.






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






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






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






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






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






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






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






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






18. Fields are specified by these






19. Returns the object matching the given lookup parameters






20. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.






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






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






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






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






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






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. Negation operator for Q objects.






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






29. This tells Django how to calculate the URL for an object. Django uses this in its admin interface - and any time it needs to figure out a URL for an object.






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






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






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






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






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






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






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






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






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






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






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






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






42. When to run syncdb






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






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






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






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


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






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






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






50. Lookup type that returns results with a case-sensitive start sequence.