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 returns results less than or equal to a given value.






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






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






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






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






6. To activate your models






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


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






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






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






11. Lookup type that yields an "exact" match. If you don't provide a lookup type -- that is - if your keyword argument doesn't contain a double underscore -- the lookup type is assumed to be of this sort.






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






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






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






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






16. This query uses an F object to increment the pingback count for every entry in the blog.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


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






18. Negation operator for Q objects.






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






20. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


21. A Manager method that returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






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






26. Can be used to remove all many-to-many relationships for an instance






27. Disjunction operator for Q objects.






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






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






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






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






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






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






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






35. Conjuntion operator for Q objects.






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






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






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






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






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






41. Takes a list of primary-key values and returns a dictionary mapping each primary-key value to an instance of the object with the given ID.






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


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






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. A convenience method for constructing an object and saving it all in one step.






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






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






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






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






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