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. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






2. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.






3. When to run syncdb






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






24. Returns the object matching the given lookup parameters






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






26. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.


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






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






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






30. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F






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






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






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






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






35. Defines a one-to-one relationship. You use it just like any other Field type: by including it as a class attribute of your model.






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






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






38. Conjuntion operator for Q objects.






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






40. These methods are intended to do "table-wide" things.






41. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.


42. Disjunction operator for Q objects.






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






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






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






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






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






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






49. Fields are specified by these






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