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

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

db.models.prefetch_related_objects()

prefetch_related_objects(model_instances, *related_lookups) [source] New in Django 1.10. Prefetches the given lookups on an iterable of model instances. This is useful in code that receives a list of model instances as opposed to a QuerySet; for example, when fetching models from a cache or instantiating them manually. Pass an iterable of model instances (must all be of the same class) and the lookups or Prefetch objects you want to prefetch for. For example: >>> from django.db.mo

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

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

db.models.Options.verbose_name_plural

Options.verbose_name_plural The plural name for the object: verbose_name_plural = "stories" If this isn’t given, Django will use verbose_name + "s".

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