Ticket #13774: rel_db_type.diff

File rel_db_type.diff, 899 bytes (added by Alexander Schepanovski, 14 years ago)
  • django/db/models/fields/related.py

     
    901901        # If the database needs similar types for key fields however, the only
    902902        # thing we can do is making AutoField an IntegerField.
    903903        rel_field = self.rel.get_related_field()
     904
     905        # Calling rel_db_type method of related field if it exists
     906        # TODO: make AutoField/PositiveIntegerField/PositiveSmallIntegerField use this method
     907        if (hasattr(rel_field, 'rel_db_type')):
     908            return rel_field.rel_db_type(connection=connection)
     909
    904910        if (isinstance(rel_field, AutoField) or
    905911                (not connection.features.related_fields_match_type and
    906912                isinstance(rel_field, (PositiveIntegerField,
Back to Top