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






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






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






4. Defines a many-to-many relationship. You use it just like any other Field type: by including it as a class attribute of your model.






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






6. restrictions on ________: (1) Your intermediate model must contain one - and only one - foreign key to the target model. (2) Your intermediate model must contain one - and only one - foreign key to the source model. (3) When defining a many-to-many r






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






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. The database that will be used if this query is executed now






11. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






37. This sets a field to a particular value for all the objects in a QuerySet. You can only set non-relation fields and ForeignKey fields using this method.






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






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






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






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






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






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


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






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






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






48. Conjuntion operator for Q objects.






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






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