Django 1.7 - makemigrations not detecting changes

前端 未结 29 1318
忘了有多久
忘了有多久 2020-11-27 12:43

As the title says, I can\'t seem to get migrations working.

The app was originally under 1.6, so I understand that migrations won\'t be there initially, and indeed i

相关标签:
29条回答
  • 2020-11-27 12:48

    This is kind of a stupid mistake to make, but having an extra comma at the end of the field declaration line in the model class, makes the line have no effect.

    It happens when you copy paste the def. from the migration, which itself is defined as an array.

    Though maybe this would help someone :-)

    0 讨论(0)
  • 2020-11-27 12:48

    Maybe this will help someone. I was using a nested app. project.appname and I actually had project and project.appname in INSTALLED_APPS. Removing project from INSTALLED_APPS allowed the changes to be detected.

    0 讨论(0)
  • 2020-11-27 12:48

    Had the same problem Make sure whatever classes you have defined in models.py, you must have to inherit models.Model class.

    class Product(models.Model):
        title = models.TextField()
        description = models.TextField()
        price = models.TextField()
    
    0 讨论(0)
  • 2020-11-27 12:48

    python manage.py makemigrations accounts Migrations for 'accounts': accounts\migrations\0001_initial.py - Create model Customer - Create model Tag - Create model Product - Create model Order

    Note: here "accounts" is my app name

    0 讨论(0)
  • 2020-11-27 12:51

    Following worked for me:

    1. Add the app name to settings.py
    2. use 'python manage.py makemigrations'
    3. use 'python manage.py migrate'

    Worked for me: Python 3.4, Django 1.10

    0 讨论(0)
  • 2020-11-27 12:52

    My solution was not covered here so I'm posting it. I had been using syncdb for a project–just to get it up and running. Then when I tried to start using Django migrations, it faked them at first then would say it was 'OK' but nothing was happening to the database.

    My solution was to just delete all the migration files for my app, as well as the database records for the app migrations in the django_migrations table.

    Then I just did an initial migration with:

    ./manage.py makemigrations my_app

    followed by:

    ./manage.py migrate my_app

    Now I can make migrations without a problem.

    0 讨论(0)
提交回复
热议问题