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 in a given list.






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






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






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






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






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






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






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






9. Evaluation happens upon use the "step" parameter of slice syntax - the first time you iterate over it - when pickling or caching results - upon calling repr() - upon calling len() - upon calling list() - upon calling bool()






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






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






31. Exception raised by get(**kwargs) if more than one item matches the query.






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






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






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






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






36. This object allows you to compare the value of a model field with another field on the same model. Django supports the use of addition - subtraction - multiplication - division and modulo arithmetic with these objects - both with constants and with o






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






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






39. To activate your models






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






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






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






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






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






45. A Python "magic method" that returns a unicode "representation" of any object.






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






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






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






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






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