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. A manager method that returns a new QuerySet containing objects that do not match the given lookup parameters.






2. By default - results returned by a QuerySet are ordered by the ordering tuple given by the ordering option in the model's Meta. You can override this on a per-QuerySet basis by using the this method.






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






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


5. Defined by a OneToOneField. You use it just like any other Field type: by including it as a class attribute of your model.






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






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






8. Fields are specified by these






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






10. Negation operator for Q objects.






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






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






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






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






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






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






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






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






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






20. In this case - an intermediate model can have multiple foreign keys to the source model. Here - two foreign keys to the same model are permitted - but they will be treated as the two (different) sides of the many-to-many relation.






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






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






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






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






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






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






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






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






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






30. To activate your models






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


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






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






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






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 field is added automatically - but this behavior can be overridden






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






38. When to run syncdb






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






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






41. Defined by a ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model.






42. Returns the object matching the given lookup parameters






43. If this option is True - the field is allowed to be blank. Default is False.






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






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






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






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






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






49. This class type is useful when you just want to use the parent class to hold information that you don't want to have to type out for each child model. This class isn't going to ever be used in isolation. When it is used as a base class for other mode






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