Apply migrations and models from all the apps

后端 未结 2 2019
孤街浪徒
孤街浪徒 2021-01-12 15:25

I\'m using Django and I have an schema like

mainapp
|---mainapp
|   |---migrations.py
|   |---models/
|---app2
    |---migrations/
    |---models/

相关标签:
2条回答
  • 2021-01-12 16:08

    first of all try

    python manage.py makemigrations
    

    for a specific app

    python manage.py makemigrations appname
    

    this will migrate all the apps

    then

    python manage.py migrate
    

    hope it helps

    0 讨论(0)
  • 2021-01-12 16:26

    Make sure you have added the app in the installed apps.

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'mainapp',
        'app2',
        #......,
        #......,
    ]
    

    Then create migrations

    using python mananage.py makemigrations and migrate with python manange.py migrate

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