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. Used to get a QuerySet for a model. This is called 'objects' by default.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






18. If this option is True - the field is allowed to be blank. Default is False.






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






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






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






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






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


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






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


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






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






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






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






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






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. Returns the object matching the given lookup parameters






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






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






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






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






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






38. When to run syncdb






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






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


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






42. This gives your model metadata.






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






44. To activate your models






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






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






47. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.






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


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






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