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






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






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






4. This field is added automatically - but this behavior can be overridden






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






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






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






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






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






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






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






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






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






14. Returns the object matching the given lookup parameters






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






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






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






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






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






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






21. Defined by django.db.models.ForeignKey. You use it just like any other Field type: by including it as a class attribute of your model.






22. Operator for comparing two model instances for equality. Behind the scenes - it compares the primary key values of two models.






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

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


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






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






26. This method is more or less the opposite of defer(). You call it with the fields that should not be deferred when retrieving a model. If you have a model where almost all the fields need to be deferred - using this method to specify the complementary






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






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






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






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






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






32. To activate your models






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






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






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






36. When to run syncdb






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






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. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.






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






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






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






43. This gives your model metadata.






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






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






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






47. Negation operator for Q objects.






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






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






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