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






2. Negation operator for Q objects.






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






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






5. Returns the most recent object in the table - by date - using the field_name provided as the date field.






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






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






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






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






10. Returns a ValuesQuerySet -- a QuerySet that returns dictionaries when used as an iterable - rather than model-instance objects.






11. Conjuntion operator for Q objects.






12. Returns an integer representing the number of objects in the database matching the QuerySet. This never raises exceptions.






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






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






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






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






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






18. When to run syncdb






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






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






21. This method is for controlling which database the QuerySet will be evaluated against if you are using more than one database. The only argument this method takes is the alias of a database - as defined in DATABASES.






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






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






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






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






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






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






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






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






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






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






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. Returns the object matching the given lookup parameters






34. The database that will be used if this query is executed now






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






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






37. Evaluates the QuerySet (by performing the query) and returns an iterator over the results. A QuerySet typically caches its results internally so that repeated evaluations do not result in additional queries; this method will instead read results dire






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






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






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






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






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






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






44. This query uses an F object to increment the pingback count for every entry in the blog.

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


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






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






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






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


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






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






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