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. The database that will be used if this query is executed now






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






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






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






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






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






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


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






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






10. Fields are specified by these






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






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


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






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






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






16. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.






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






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






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






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






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






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






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






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






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






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






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

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


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






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






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






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. The default for this is the name of the child class followed by '_set'.






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






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






35. When to run syncdb






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






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






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






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






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






41. A convenience method for constructing an object and saving it all in one step.






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






43. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.






44. Negation operator for Q objects.






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






46. This gives your model metadata.






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






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






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






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