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 an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.






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






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






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






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






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






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






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






9. Returns a copy of the current QuerySet (or QuerySet subclass you pass in). This can be useful in some situations where you might want to pass in either a model manager or a QuerySet and do further filtering on the result. You can safely call all() on






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






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






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






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






14. Used to get a QuerySet for a model. This is called 'objects' by default.






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






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






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






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






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






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






21. Disjunction operator for Q objects.






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






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






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






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






26. In some complex data-modeling situations - your models might contain a lot of fields - some of which could contain a lot of data (for example - text fields) - or require expensive processing to convert them to Python objects. If you are using the res






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






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






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






30. Negation operator for Q objects.






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






32. Each one of these is a Python class that subclasses django.db.models.Model. Each attribute of one of these represents a database field.






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






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






36. Fields are specified by these






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






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






39. This gives your model metadata.






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






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






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






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






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






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






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






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






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






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






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