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. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






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






6. When to run syncdb






7. Conjuntion operator for Q objects.






8. what the field _______ determines: (1) The database column type (e.g. INTEGER - VARCHAR); (2) The widget to use in Django's admin interface - if you care to use it (e.g. <input type="text"> - <select>); (3) The minimal validation requirements - used






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






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






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






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






13. Lookup type that finds a case-insensitive regular expression match.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






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






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






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






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






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






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






40. Returns the object matching the given lookup parameters






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






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


43. Can be used to remove all many-to-many relationships for an instance






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






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






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






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






48. Disjunction operator for Q objects.






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






50. This gives your model metadata.