Devinwon / article

0 stars 0 forks source link

create table failed in django (ORM) #29

Open Devinwon opened 5 years ago

Devinwon commented 5 years ago

如果连的是mysql数据库,在表django_migrations中删除name为你建立的app名字的记录, 类似 delete from django_migrations where name='your app name';

然后重新run python manage.py makemigrations python manange.py migrate

原先已经存在的建表记录导致没能创建表成功,发现很多情况创建表不成功,或者没有及时得到更新,都会出现问题

注意:在app下的migrations文件夹不要删除,以及下面的ini.py初始文件

=========================== How to rebuild a table when update ouccured drop table in database commet your model will be rebuilt run the below commands: python manage.py makemigrates python manage.py migrate --fake

cancel commet on your model run the create table commands below: python manage.py makemigrates python manage.py migrate

perevertysh commented 5 years ago

try to delete all migrations in your apps, then make: makemigrations; migrate; again

Devinwon commented 5 years ago

Thank you.