zoukankan      html  css  js  c++  java
  • Django学习中遇到的问题(1)django migration No migrations to apply

    C:UsersDesktophomeWorkDjango_stu_man>python manage.py makemigrations
    Migrations for 'app01':
      app01migrations001_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:UsersDesktophomeWorkDjango_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:UsersDesktophomeWorkDjango_stu_man>python manage.py makemigrations
    No changes detected
    
    C:UsersDesktophomeWorkDjango_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

  • 相关阅读:
    JQuery是继prototype之后又一个优秀的Javascript库
    IAsyncResult接口
    Asynchronous Programming Patterns
    操作数据库的时候,使用自带的DbProviderFactory类 (涉及抽象工厂和工厂方法)
    8.2.4对象之间的关系
    git squash 和 git rebase
    8.2.3多态性 第8章 面向对象编程简介
    github的使用教程
    第7章 调试和错误处理 7.1.1 VS中的调试
    markdown的语法说明
  • 原文地址:https://www.cnblogs.com/william126/p/7591562.html
Copyright © 2011-2022 走看看