db.models.Field.rel_db_type()

rel_db_type(connection) [source]

New in Django 1.10.

Returns the database column data type for fields such as ForeignKey and OneToOneField that point to the Field, taking into account the connection.

See Custom database types for usage in custom fields.

There are three main situations where Django needs to interact with the database backend and fields:

  • when it queries the database (Python value -> database backend value)
  • when it loads data from the database (database backend value -> Python value)
  • when it saves to the database (Python value -> database backend value)

When querying, get_db_prep_value() and get_prep_value() are used:

doc_Django
2016-10-09 18:35:29
Comments
Leave a Comment

Please login to continue.