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






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






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






4. True if the QuerySet has an order_by() clause or a default ordering on the model. False otherwise.






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






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






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






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






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






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






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


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






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






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






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






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






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






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


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






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






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


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






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






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






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






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






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






29. This method immediately deletes the object and has no return value.






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






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






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






33. These add custom "row-level" functionality to your objects. These act on a particular model instance.






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






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






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






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






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






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






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






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






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






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






44. Use this method to reverse the order in which a queryset's elements are returned. Calling this method a second time restores the ordering back to the normal direction.






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






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






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






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






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






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