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 model method saves a model instance to the database. This method has no return value.






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






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






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






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






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






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






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






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






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






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






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






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






14. Fields are specified by these






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






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






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






18. This query finds all entries with an id in the list [1 - 3 - 4]






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






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






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






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






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






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






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






27. A manager method which returns a single object. If there are no results that match the query - this method will raise a DoesNotExist exception. If more than one item matches this query - the method will raise MultipleObjectsReturned.






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






29. Conjuntion operator for Q objects.






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






31. Returns the object matching the given lookup parameters






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






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






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






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






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






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






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






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






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






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






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






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






44. When to run syncdb






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






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






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






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






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






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