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






2. This gives your model metadata.






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






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






6. Adds to each object in the QuerySet with the provided list of aggregate values (averages - sums - etc) that have been computed over the objects that are related to the objects in the QuerySet. Each argument to this is content that will be added to ea






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






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






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






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






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






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






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






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






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


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






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






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






19. Takes a list of primary-key values and returns a dictionary mapping each primary-key value to an instance of the object with the given ID.






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


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






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






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






24. Disjunction operator for Q objects.






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






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






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






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


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






30. This model method is used for updating a ManyToManyField.






31. If True - the table does not permit duplicate values for this field.






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






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






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






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






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






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






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






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






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






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






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






43. To activate your models






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






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






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






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






48. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.






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






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