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






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






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






4. Lookup type that returns results less than a given value.






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






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






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






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






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






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






11. Returns the object matching the given lookup parameters






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. Lookup type that returns results that fall into an inclusive date range.






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


15. This gives your model metadata.






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






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






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






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






20. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






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






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






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






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






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






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






27. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.






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






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






30. This is a criterion that narrow down a QuerySet based on given parameters.






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






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






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






34. Adds to each object in the QuerySet with the provided list of aggregate values (averages - sums - etc) that have been computed over the objects that are related to the objects in the QuerySet. Each argument to this is content that will be added to ea






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






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






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






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






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






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


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






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






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






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






45. To activate your models






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


47. Disjunction operator for Q objects.






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






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






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