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






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






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






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






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






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


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






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






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






10. This query finds all entries between a start date of start_date and an end date of end_date.






11. Evaluates the QuerySet (by performing the query) and returns an iterator over the results. A QuerySet typically caches its results internally so that repeated evaluations do not result in additional queries; this method will instead read results dire






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






13. Specifies the model that will be used to govern the many-to-many relationship. You can then put extra fields on the intermediate model. The intermediate model is associated with the ManyToManyField using this to point to the model that will act as an






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






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


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






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






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






19. The database that will be used if this query is executed now






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






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






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






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. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.






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






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






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






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






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


31. This method returns tuples of values when iterated over. Each tuple contains the value from the respective field passed into the call to this method -- so the first item is the first field - etc.






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






33. This gives your model metadata.






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






35. Disjunction operator for Q objects.






36. Returns the object matching the given lookup parameters






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






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






39. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






48. When to run syncdb






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






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