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






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


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






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






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






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






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






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






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






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






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






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






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


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






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






16. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.






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






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






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






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






21. Disjunction operator for Q objects.






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






23. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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






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






26. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r






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






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


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






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






31. Defines a many-to-many relationship. You use it just like any other Field type: by including it as a class attribute of your model.






32. When to run syncdb






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






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


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






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






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






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






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






40. By default - results returned by a QuerySet are ordered by the ordering tuple given by the ordering option in the model's Meta. You can override this on a per-QuerySet basis by using the this method.






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






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






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






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






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






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






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






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






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






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