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. Lookup type that tests for inclusion in a case-sensitive fashion.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






18. Manager method used to retrieve every object in a model.






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


20. This gives your model metadata.






21. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






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






23. Returns the object matching the given lookup parameters






24. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.






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






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






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






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






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






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






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






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






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






34. This query finds all entries with an id greater than 4.






35. An iterable (e.g. - a list or tuple) of 2-tuples to use as options for this field. If this is given - Django's admin will use a select box instead of the standard text field and will limit options to those given.






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






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






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






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






40. Fields are specified by these






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


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






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






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






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






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






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






48. To activate your models






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






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