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. This query updates all the headlines with pub_date in 2007 to read 'Everything is the same'.


2. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.






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






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






5. Returns the object matching the given lookup parameters






6. Conjuntion operator for Q objects.






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






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






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






10. Exception raised by get(**kwargs) if no items match the query.






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






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






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






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






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






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






17. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.


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






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






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






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






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






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






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






25. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






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






27. When to run syncdb






28. To activate your models






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






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






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






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






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






34. A Python "magic method" that returns a unicode "representation" of any object.






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


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






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


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






39. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






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






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






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