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. Lookup type that returns results less than or equal to a given value.






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






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






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


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






6. Returns the object matching the given lookup parameters






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






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






9. When to run syncdb






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






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


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






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






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






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






16. These are "anything that's not a field" - such as ordering options (ordering) - database table name (db_table) - or human-readable singular and plural names (verbose_name and verbose_name_plural)






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






18. Conjuntion operator for Q objects.






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






20. Fields are specified by these






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






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






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






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






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






26. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.






27. This gives your model metadata.






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






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






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






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






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






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






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






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






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






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






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






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






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






41. To activate your models






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






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






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






45. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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






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






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






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