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

db.models.Options.required_db_vendor

Options.required_db_vendor New in Django 1.9. Name of a supported database vendor that this model is specific to. Current built-in vendor names are: sqlite, postgresql, mysql, oracle. If this attribute is not empty and the current connection vendor doesn’t match it, the model will not be synchronized.

db.models.Options.required_db_features

Options.required_db_features New in Django 1.9. List of database features that the current connection should have so that the model is considered during the migration phase. For example, if you set this list to ['gis_enabled'], the model will only be synchronized on GIS-enabled databases. It’s also useful to skip some models when testing with several database backends. Avoid relations between models that may or may not be created as the ORM doesn’t handle this.

db.models.Options.proxy

Options.proxy If proxy = True, a model which subclasses another model will be treated as a proxy model.

db.models.Options.permissions

Options.permissions Extra permissions to enter into the permissions table when creating this object. Add, delete and change permissions are automatically created for each model. This example specifies an extra permission, can_deliver_pizzas: permissions = (("can_deliver_pizzas", "Can deliver pizzas"),) This is a list or tuple of 2-tuples in the format (permission_code, human_readable_permission_name).

db.models.Options.order_with_respect_to

Options.order_with_respect_to Makes this object orderable with respect to the given field, usually a ForeignKey. This can be used to make related objects orderable with respect to a parent object. For example, if an Answer relates to a Question object, and a question has more than one answer, and the order of answers matters, you’d do this: from django.db import models class Question(models.Model): text = models.TextField() # ... class Answer(models.Model): question = models.Fo

db.models.Options.ordering

Options.ordering The default ordering for the object, for use when obtaining lists of objects: ordering = ['-order_date'] This is a tuple or list of strings. Each string is a field name with an optional “-” prefix, which indicates descending order. Fields without a leading “-” will be ordered ascending. Use the string ”?” to order randomly. For example, to order by a pub_date field ascending, use this: ordering = ['pub_date'] To order by pub_date descending, use this: ordering = ['-pub_dat

db.models.options.Options.get_fields()

Options.get_fields(include_parents=True, include_hidden=False) [source] Returns a tuple of fields associated with a model. get_fields() accepts two parameters that can be used to control which fields are returned: include_parents True by default. Recursively includes fields defined on parent classes. If set to False, get_fields() will only search for fields declared directly on the current model. Fields from models that directly inherit from abstract models or proxy classes are considered

db.models.options.Options.get_field()

Options.get_field(field_name) [source] Returns the field instance given a name of a field. field_name can be the name of a field on the model, a field on an abstract or inherited model, or a field defined on another model that points to the model. In the latter case, the field_name will be the related_name defined by the user or the name automatically generated by Django itself. Hidden fields cannot be retrieved by name. If a field with the given name is not found a FieldDoesNotExist excepti

db.models.options.Options

class Options [source] The model _meta API is at the core of the Django ORM. It enables other parts of the system such as lookups, queries, forms, and the admin to understand the capabilities of each model. The API is accessible through the _meta attribute of each model class, which is an instance of an django.db.models.options.Options object. Methods that it provides can be used to: Retrieve all field instances of a model Retrieve a single field instance of a model by name