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






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






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






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






5. If you are using this attribute on a ForeignKey or ManyToManyField - you must always specify a unique reverse name for the field.






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






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






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






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






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






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. Lookup type that returns results greater than a given value.






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






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






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






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






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






18. If this option is True - Django will store empty values as NULL in the database. Default is False.






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






20. Lookup type that corresponds to a boolean full-text search - taking advantage of full-text indexing. This is like contains but is significantly faster due to full-text indexing.






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






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






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






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






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






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






27. Negation operator for Q objects.






28. Returns the most recent object in the table - by date - using the field_name provided as the date field.






29. Performs an SQL delete query on all rows in the QuerySet. This method is applied instantly. You cannot call this method on a QuerySet that has had a slice taken or can otherwise no longer be filtered.






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






31. Takes the ouput of one filter and uses it as input for another filter. This works because a refinement of a QuerySet is itself a QuerySet.






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






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






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






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






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






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






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






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






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






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






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






43. Conjuntion operator for Q objects.






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






45. When to run syncdb






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






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






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


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






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