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






3. This query finds all entries with an id greater than 4.






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






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






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






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






8. Takes a list of primary-key values and returns a dictionary mapping each primary-key value to an instance of the object with the given ID.






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






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






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






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






13. If this option is True - the field is allowed to be blank. Default is False.






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






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






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






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






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






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






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






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






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






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






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


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






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






28. This gives your model metadata.






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






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






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






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






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






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






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






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






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






38. Returns the object matching the given lookup parameters






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






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






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






42. Extra text to be displayed under the field on the object's admin form to provide assistance to users. It's useful for documentation even if your object doesn't have an admin form.






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






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






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






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






47. The first element in this iterable is the value that will be stored in the database - the second element will be displayed by the admin interface - or in a ModelChoiceField.






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






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






50. Disjunction operator for Q objects.






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