每次我通過SSH登錄到我的服務器我需要鍵入以下內容:爲什麼我需要DJANGO_SETTINGS_MODULE集?
export DJANGO_SETTINGS_MODULE=settings
,如果我不把manage.py模塊的任何使用失敗
我manage.py具有以下添加代碼:
if "notification" in settings.INSTALLED_APPS:
from notification import models as notification
def create_notice_types(app, created_models, verbosity, **kwargs):
notification.create_notice_type("friends_invite", _("Invitation Received"), _("you have received an invitation"))
notification.create_notice_type("friends_accept", _("Acceptance Received"), _("an invitation you sent has been accepted"))
signals.post_syncdb.connect(create_notice_types, sender=notification)
else:
print "Skipping creation of NoticeTypes as notification app not found"
任何想法?
謝謝你的回覆。 你的意思是不推薦使用,因爲降低了可移植性? 請解釋原因。 – RadiantHex 2010-01-20 16:00:30
是的,它降低了便攜性。應該避免將管理工具與應用程序耦合在一起。應用程序和項目都應該有獨立移動的部分。想象一下未來,您需要將應用程序移動到另一個項目,或從當前項目中移除一個應用程序。最好不要讓它們交織在一起,而是從應用程序本身內部(安全地)執行任何類型的檢查。 – jathanism 2010-01-20 16:06:16