Django学习中遇到的问题(1)django migration No migrations to apply

C:\Users\Desktop\homeWork\Django_stu_man>python manage.py makemigrations
Migrations for 'app01':
  app01\migrations\0001_initial.py
    - Create model ClassList
    - Create model Course
    - Create model CourseRecord
    - Create model Customer
    - Create model CustomerFollowRecord
    - Create model School
    - Create model StudyRecord
    - Create model UserProfile
    - Add field follower to customerfollowrecord
    - Add field consultant to customer
    - Add field course to customer
    - Add field referral_form to customer
    - Add field teacher to courserecord
    - Add field course to classlist
    - Add field teachers to classlist
    - Alter unique_together for courserecord (1 constraint(s))
    - Alter unique_together for classlist (1 constraint(s))

C:\Users\Desktop\homeWork\Django_stu_man>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, app01, auth, contenttypes, sessions
Running migrations:
  No migrations to apply.

如上所示,建完表之后,运行python manage.py migrate,总是No migrations to apply,数据库中表也没有建成。

通过查阅资料,大部分建议都是先运行python manage.py makemigrations,再运行python manage.py migrate,然并卵。

最后在stackoverflow上发现了正解。

 

Django keeps track of all the applied migrations in django_migrations table. So just delete all the rows in the django_migrations table that are related to you app like:

DELETE FROM django_migrations WHERE app='your-app-name';

and then do:

python manage.py makemigrations
python manage.py migrate

 

C:\Users\Desktop\homeWork\Django_stu_man>python manage.py makemigrations
No changes detected

C:\Users\Desktop\homeWork\Django_stu_man>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, app01, auth, contenttypes, sessions
Running migrations:
  Applying app01.0001_initial... OK

 

binggo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

https://stackoverflow.com/questions/33549772/django-migration-no-migrations-to-apply

转载于:https://www.cnblogs.com/william126/p/7591562.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值