db.models.query.QuerySet

class QuerySet(model=None, query=None, using=None) [source] Usually when you’ll interact with a QuerySet you’ll use it by chaining filters. To make this work, most QuerySet methods return new querysets. These methods are covered in detail later in this section. The QuerySet class has two public attributes you can use for introspection: ordered True if the QuerySet is ordered — i.e. has an order_by() clause or a default ordering on the model. False otherwise. db The database that wil

db.models.PROTECT

PROTECT [source] Prevent deletion of the referenced object by raising ProtectedError, a subclass of django.db.IntegrityError.

db.models.Q

class Q [source] A Q() object, like an F object, encapsulates a SQL expression in a Python object that can be used in database-related operations. In general, Q() objects make it possible to define and reuse conditions. This permits the construction of complex database queries using | (OR) and & (AND) operators; in particular, it is not otherwise possible to use OR in QuerySets.

db.models.PositiveIntegerField

class PositiveIntegerField(**options) [source] Like an IntegerField, but must be either positive or zero (0). Values from 0 to 2147483647 are safe in all databases supported by Django. The value 0 is accepted for backward compatibility reasons.

db.models.PositiveSmallIntegerField

class PositiveSmallIntegerField(**options) [source] Like a PositiveIntegerField, but only allows values under a certain (database-dependent) point. Values from 0 to 32767 are safe in all databases supported by Django.

db.models.output_field

output_field Defines the type of class returned by the get_lookup() method. It must be a Field instance.

db.models.Prefetch

class Prefetch(lookup, queryset=None, to_attr=None) [source] The Prefetch() object can be used to control the operation of prefetch_related(). The lookup argument describes the relations to follow and works the same as the string based lookups passed to prefetch_related(). For example: >>> Question.objects.prefetch_related(Prefetch('choice_set')).get().choice_set.all() <QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]> # This wil

db.models.Options.unique_together

Options.unique_together Sets of field names that, taken together, must be unique: unique_together = (("driver", "restaurant"),) This is a tuple of tuples that must be unique when considered together. It’s used in the Django admin and is enforced at the database level (i.e., the appropriate UNIQUE statements are included in the CREATE TABLE statement). For convenience, unique_together can be a single tuple when dealing with a single set of fields: unique_together = ("driver", "restaurant")

db.models.Options.verbose_name

Options.verbose_name A human-readable name for the object, singular: verbose_name = "pizza" If this isn’t given, Django will use a munged version of the class name: CamelCase becomes camel case.

db.models.Options.select_on_save

Options.select_on_save Determines if Django will use the pre-1.6 django.db.models.Model.save() algorithm. The old algorithm uses SELECT to determine if there is an existing row to be updated. The new algorithm tries an UPDATE directly. In some rare cases the UPDATE of an existing row isn’t visible to Django. An example is the PostgreSQL ON UPDATE trigger which returns NULL. In such cases the new algorithm will end up doing an INSERT even when a row exists in the database. Usually there is no