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 Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






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






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






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






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






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






10. This method is for controlling which database the QuerySet will be evaluated against if you are using more than one database. The only argument this method takes is the alias of a database - as defined in DATABASES.






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






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






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






14. Negation operator for Q objects.






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






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






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






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






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






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






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






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






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






24. Used to get a QuerySet for a model. This is called 'objects' by default.






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






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






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






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






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






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






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






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






34. Returns an EmptyQuerySet -- a QuerySet that always evaluates to an empty list. This can be used in cases where you know that you should return an empty result set and your caller is expecting a QuerySet object (instead of returning an empty list - fo






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






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






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






38. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






47. When to run syncdb






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






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






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