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






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


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






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






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






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






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






8. To activate your models






9. Fields are specified by these






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






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






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






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






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






15. Negation operator for Q objects.






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






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






18. Returns the object matching the given lookup parameters






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






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






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






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






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






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






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






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






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






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






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






30. A Q object that encapsulates queries for entries with a question value that starts with 'What' in a case-insensitive fashion.

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


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






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






33. Lookup type that returns results with a case-insensitive end sequence.






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






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






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






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






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






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






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


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






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






43. Conjuntion operator for Q objects.






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






45. This class type is useful when you just want to use the parent class to hold information that you don't want to have to type out for each child model. This class isn't going to ever be used in isolation. When it is used as a base class for other mode






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


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


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






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






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