How do I use Django South when my app is inside another directory?

▼魔方 西西 提交于 2019-12-25 06:39:10

问题


So by default, Django creates apps inside the root project dir. But I moved it inside "apps".

py manage.py  schemamigration ./apps/chat --initial

This doesn't work.

Instead of "chat", I put "chat" Inside another directory.


回答1:


is apps python module or just directory?

if apps python modue, add apps.chat to installed apps in settings.py

and run

py manage.py  schemamigration chat --initial

if apps is just directory, so you need to add this directory to your PYTHONPATH. add these lines at near top of your manage.py

import os
import sys
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
APPS_ROOT = os.path.join(SITE_ROOT, 'apps')
sys.path.append(APPS_ROOT)

add chat to your settings.

now run

py manage.py  schemamigration chat --initial

and don't forget to add south to installed apps for both.



来源:https://stackoverflow.com/questions/5784803/how-do-i-use-django-south-when-my-app-is-inside-another-directory

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