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. Lookup type that returns results greater than a given value.






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






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


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






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






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






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






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






9. When to run syncdb






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






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






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






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






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






15. This gives your model metadata.






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






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






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






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






20. Lookup type that returns results with a case-sensitive start sequence.






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






22. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.






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


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






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






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






27. Conjuntion operator for Q objects.






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






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






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






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






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






33. To activate your models






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






35. This method is for controlling which database the QuerySet will be evaluated against if you are using more than one database. The only argument this method takes is the alias of a database - as defined in DATABASES.






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






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






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






39. Returns a copy of the current QuerySet (or QuerySet subclass you pass in). This can be useful in some situations where you might want to pass in either a model manager or a QuerySet and do further filtering on the result. You can safely call all() on






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






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






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






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


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






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






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






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






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






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