[Django]-Issue while creating Foreign Key constraint

6👍

Override rel_db_type to return similar to db_type without AUTO_INCREMENT.

class TinyIntField(AutoField):
    def db_type(self, connection):
        return "tinyint(3) AUTO_INCREMENT"

    def rel_db_type(self, connection):
        return "tinyint(3)"

Reference: https://docs.djangoproject.com/en/3.2/howto/custom-model-fields/#custom-database-types

👤aaron

Leave a comment