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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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. This gives your model metadata.






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






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






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






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






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






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






25. Fields are specified by these






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






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






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






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






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






31. Returns True if the QuerySet contains any results - and False if not. This tries to perform the query in the simplest and fastest way possible - but it does execute nearly the same query. This means that calling this method on a queryset is faster th






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






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






34. When to run syncdb






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






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






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






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






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






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






41. Conjuntion operator for Q objects.






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






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






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






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






46. To activate your models






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






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






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


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