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. If True - this field is the primary key for the model.






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






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






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






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






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






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






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






9. Sometimes - the Django query syntax by itself can't easily express a complex WHERE clause. For these edge cases - Django provides this QuerySet modifier -- a hook for injecting specific clauses into the SQL generated by a QuerySet.






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






11. These add custom "row-level" functionality to your objects. These act on a particular model instance.






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






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






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






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






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






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






18. Lookup type that returns results with a case-insensitive end sequence.






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






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






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






22. Negation operator for Q objects.






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






24. If this option is True - Django will store empty values as NULL in the database. Default is False.






25. Lookup type for date/datetime fields that finds a 'day of the week' match.






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






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






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






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


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






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






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






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






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






35. Conjuntion operator for Q objects.






36. This style of inheritanc is useful when you're subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table. Here - each model in the hierarchy is a model all by itself.






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. Lookup type that returns results that fall into an inclusive date range.






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






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






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






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






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


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






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






46. Fields are specified by these






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






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






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






50. When to run syncdb







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