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. a QuerySet can be sliced - using Python's array-slicing syntax.






2. (1) These cannot be Python reserved words - because that would result in a Python syntax error. (2) These cannot contain more than one underscore in a row - due to the way Django's query lookup syntax works.






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






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






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






6. This query deletes all Entry objects with a pub_date year of 2005.






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






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






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






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






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






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






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






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


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






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






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






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






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






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






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


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






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






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






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






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






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






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






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






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






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


32. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.






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






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






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






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






37. Lookup type for date/datetime fields that finds an exact month match. Takes an integer 1 (January) through 12






38. These are "anything that's not a field" - such as ordering options (ordering) - database table name (db_table) - or human-readable singular and plural names (verbose_name and verbose_name_plural)






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






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






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






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






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






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






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






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






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






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






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






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