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. The default for this is the name of the child class followed by '_set'.






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






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






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






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






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






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






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






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






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






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






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






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






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






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






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


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






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






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






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


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






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






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






24. Lookup type that returns results with a case-sensitive end sequence.






25. This gives your model metadata.






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






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






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






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






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






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






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






33. Conjuntion operator for Q objects.






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






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






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






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






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






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






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


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






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






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






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






45. To activate your models






46. Fields are specified by these






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






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






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






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






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