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. This query finds all entries with an id greater than 4.






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






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






5. what the field _______ determines: (1) The database column type (e.g. INTEGER - VARCHAR); (2) The widget to use in Django's admin interface - if you care to use it (e.g. <input type="text"> - <select>); (3) The minimal validation requirements - used






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






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






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






9. Negation operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






27. Returns a QuerySet that will automatically "follow" foreign-key relationships - selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later u






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






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






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






31. This query uses an F object to increment the pingback count for every entry in the blog.

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


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






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






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






35. Fields are specified by these






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






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






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


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






40. Lookup type that returns results with a case-insensitive end sequence.






41. This gives your model metadata.






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






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






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






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






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






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






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






49. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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