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


2. This gives your model metadata.






3. Fields are specified by these






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






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






6. Lookup type that returns results that fall into an inclusive date range.






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






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






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






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






11. This model method saves a model instance to the database. This method has no return value.






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






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






14. To activate your models






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






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






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






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






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






20. Conjuntion operator for Q objects.






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






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






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






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






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






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






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






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






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






30. a QuerySet can be sliced - using Python's array-slicing syntax.






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






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






33. A manager method which returns a single object. If there are no results that match the query - this method will raise a DoesNotExist exception. If more than one item matches this query - the method will raise MultipleObjectsReturned.






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






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






36. When to run syncdb






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






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






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






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






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






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






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


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






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






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






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






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






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






50. Lookup type that returns results less than or equal to a given value.