独立Django应用中的迁移 [英] Migrations in stand alone Django app
本文介绍了独立Django应用中的迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在独立的Django应用程序上进行迁移(即,如果有任何项目,该应用程序将不包含在内)。
How do I makemigrations on a stand alone Django app (ie one that is not part if any project).
例如,执行以下操作: https://docs.djangoproject.com/en/1.8/intro/reusable-apps/
For example after following: https://docs.djangoproject.com/en/1.8/intro/reusable-apps/
推荐答案
您可以执行类似于测试应用程序脚本的方式:
You can do it similar to how you do testing scripts for apps:
#!/usr/bin/env python
import sys
import django
from django.conf import settings
from django.core.management import call_command
settings.configure(DEBUG=True,
INSTALLED_APPS=(
'django.contrib.contenttypes',
'your_app',
),
)
django.setup()
call_command('makemigrations', 'your_app')
这篇关于独立Django应用中的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文