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. When to run syncdb






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






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






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






31. Lookup type for date/datetime fields that finds an exact year match. Takes a four-digit year.






32. These methods are intended to do "table-wide" things.






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






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






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






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






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






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






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






40. Returns a dictionary of aggregate values (averages - sums - etc) calculated over the QuerySet. Each argument to this method specifies a value that will be included in the dictionary that is returned.






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






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






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






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






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






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






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






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


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






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