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. Can be used to remove all many-to-many relationships for an instance






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






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






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






5. This method is more or less the opposite of defer(). You call it with the fields that should not be deferred when retrieving a model. If you have a model where almost all the fields need to be deferred - using this method to specify the complementary






6. This gives your model metadata.






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






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






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






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






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






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






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






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






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






16. A Q object that asks for entries with a question value that start with 'Who' or do not have a publication date of 2005.

Warning: Invalid argument supplied for foreach() in /var/www/html/basicversity.com/show_quiz.php on line 183


17. To activate your models






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






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






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






21. Lookup type that returns results greater than or equal to a given value.






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






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






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






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






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






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






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






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






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


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






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


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






34. Disjunction operator for Q objects.






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






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






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






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






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






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






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






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






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. Lookup type that returns results with a case-sensitive start sequence.






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






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






47. Negation operator for Q objects.






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






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. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.