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






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






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. Lookup type that returns results less than a given value.






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






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






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






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






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






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






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






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






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






14. Fields are specified by these






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






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






17. Accomplish this by using the field name of related fields across models - separated by double underscores - until you get to the field you want. For example - to get all Entry objects with a Blog whose name is 'Beatles Blog': Entry.objects.filter(blo






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






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






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






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






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






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


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


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






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






27. Negation operator for Q objects.






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






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






30. This gives your model metadata.






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






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






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






34. The value given in the absence of a specified value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created.






35. When to run syncdb






36. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.






37. The default for this is the name of the child class followed by '_set'.






38. Conjuntion operator for Q objects.






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






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






41. Here - you can't use add - create - or assignment (i.e. - beatles.members = [...]) to create relationships. You need to specify all the detail for the relationship required by the intermediate model.






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






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






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






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






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






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






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






49. To activate your models






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







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