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






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






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






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






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


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


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






8. Fields are specified by these






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






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






11. Lookup type that returns results in a given list.






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






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






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






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






16. When to run syncdb






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






35. Disjunction operator for Q objects.






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






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






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






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






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






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






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






43. This query deletes all Entry objects with a pub_date year of 2005.






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






45. Lookup type that returns results less than or equal to a given value.






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






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






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






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


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







Sorry!:) No result found.

Can you answer 50 questions in 15 minutes?


Let me suggest you:



Major Subjects



Tests & Exams


AP
CLEP
DSST
GRE
SAT
GMAT

Most popular tests