当我的应用位于另一个目录中时,如何使用Django South? [英] How do I use Django South when my app is inside another directory?

查看:80
本文介绍了当我的应用位于另一个目录中时,如何使用Django South?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,默认情况下,Django在根项目目录中创建应用.但我将其移至应用程序"中.

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

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

这不起作用.

我将聊天"放置在另一个目录中,而不是聊天".

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

推荐答案

应用是python模块还是目录?

is apps python module or just directory?

如果应用为python模式, 在settings.py中将apps.chat添加到已安装的应用程序

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

并运行

py manage.py  schemamigration chat --initial

如果应用仅仅是目录,那么您需要将此目录添加到您的PYTHONPATH中. 在您的manage.py

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.

现在运行

py manage.py  schemamigration chat --initial

并且不要忘记为这两个应用程序都添加了内容.

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

这篇关于当我的应用位于另一个目录中时,如何使用Django South?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆