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. These methods are intended to do "table-wide" things.






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






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






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






6. When to run syncdb






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






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






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






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






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






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






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






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






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






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






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






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






19. To activate your models






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






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






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. These are specified as keyword arguments to the QuerySet methods filter() - exclude() and get(). These take the form field__lookuptype=value .






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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






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






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






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






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






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







Sorry!:) No result found.

Can you answer 50 questions in 15 minutes?


Let me suggest you:



Major Subjects



Tests & Exams


AP
CLEP
DSST
GRE
SAT
GMAT

Most popular tests