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






2. (1) These cannot be Python reserved words - because that would result in a Python syntax error. (2) These cannot contain more than one underscore in a row - due to the way Django's query lookup syntax works.






3. This object encapsulates a collection of keyword arguments - with the keys being field lookup types. These objects can be combined using the & and | operators - as well as negated with the ~ operator.






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






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






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






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






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






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






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


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






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






13. Negation operator for Q objects.






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






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






16. This gives your model metadata.






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






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






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






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






21. Performs an SQL update query for the specified fields - and returns the number of rows affected. This method is applied instantly and the only restriction on the QuerySet that is updated is that it can only update columns in the model's main table. F






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


23. This model type is useful if you only want to modify the Python-level behavior of a model - without changing the models fields in any way. This creates a stand-in for the original model. You can create - delete and update instances of this new model






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






45. To activate your models






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






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






48. When to run syncdb






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






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