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






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






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






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






5. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.






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






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






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






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






10. Fields are specified by these






11. Returns the object matching the given lookup parameters






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






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






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






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






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






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






18. When to run syncdb






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






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






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






22. This object allows you to compare the value of a model field with another field on the same model. Django supports the use of addition - subtraction - multiplication - division and modulo arithmetic with these objects - both with constants and with o






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






24. To activate your models






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






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






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






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






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






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






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






32. Extra text to be displayed under the field on the object's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form.






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






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






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






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






37. Returns a DateQuerySet -- a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.

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


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






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






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






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






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






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






44. A QuerySet is iterable - and it executes its database query the first time you iterate over it.






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






46. This gives your model metadata.






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






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






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






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