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






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






3. Conjuntion operator for Q objects.






4. To activate your models






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






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






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






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






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






10. When to run syncdb






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






12. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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






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






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






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






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






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






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






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 query deletes all Entry objects with a pub_date year of 2005.






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






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






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






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






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






27. Returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






31. Negation operator for Q objects.






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






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






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






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






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






37. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo






38. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo






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






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






41. Fields are specified by these






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






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






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






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






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






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






48. Returns the object matching the given lookup parameters






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






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