Django unique=True not working

后端 未结 3 1472
暗喜
暗喜 2020-12-23 18:03

This is from django\'s documentation:

Field.unique

If True, this field must be unique throughout the table.

This is enforced at the databas

3条回答
  •  我在风中等你
    2020-12-23 18:27

    The solution is pretty simple, Just follow their steps.

    1 - Dell all the files in the migration folder
    2 - Then run the command "python manage.py makemigrations"
    3 - Then run the command "python manage.py migrate"
    

    OR

    Do it by the help of a simple SQL-lite Query Adding index Example

    alter table test add index index_name(col1(255),col2(255));

    Adding unique index Example

    alter table test add unique index_name(col1(255),col2(255));

提交回复
热议问题