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






3. Conjuntion operator for Q objects.






4. Disjunction operator for Q objects.






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






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


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






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






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






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






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






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


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






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






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






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






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






18. When to run syncdb






19. Returns the object matching the given lookup parameters






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






21. Negation operator for Q objects.






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






23. Fields are specified by these






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






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






26. To activate your models






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






28. Lookup type that takes either True or False and corresponds to SQL queries of IS NULL and IS NOT NULL - respectively.






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






30. Lookup type for date/datetime fields that finds a 'day of the week' match.






31. Returns a new QuerySet containing objects that match the given lookup parameters.






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






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






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






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






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






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






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






39. This method returns tuples of values when iterated over. Each tuple contains the value from the respective field passed into the call to this method -- so the first item is the first field - etc.






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






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






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






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






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






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






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






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






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. This is a criterion that narrow down a QuerySet based on given parameters.






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