Apply migrations and models from all the apps

好久不见. 提交于 2020-03-16 05:20:04

问题


I'm using Django and I have an schema like

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

But, when I execute:

python manage.py migrate it is generationg the tables of mainapp/models, but no the app2/models and app2/migrations either.

How can execute those migrations?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/43992101/apply-migrations-and-models-from-all-the-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!