2017-09-21 10 views
1

Django:サイトフレームワークを使用して複数のsettings.pyファイルを含める(または動的SITE_IDを含める)適切な方法は何ですか?私は生産に私のDjangoのサイトで、このエラーを取得してい

You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting or pass a request to Site.objects.get_current() to fix this error.

質問はhereを頼まれましたが、受け入れられた答えは、生産のrunserverを使用することを提案しています。

hereでも受け付けられた回答は不問です。

私はsettings.pyファイルに以下を追加しようとしましたが、それはエラーがスローされます。

from django.contrib.sites.models import Site 
SITE_ID = Site.objects.get_current() 

エラーは次のとおりです。

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

...しかし、私はSECRET_KEY設定セットを持っています。

Django documentationを同じサーバー上の複数のサーバーに接続する適切な方法は何ですか?

答えて

0

ここに答えがSites framework middlewareを含めるようにした。

'django.contrib.sites.middleware.CurrentSiteMiddleware' 

これは、自動的にエラー通知あたりのすべての要求にSite.objects.get_current()requestオブジェクトを渡します。

関連する問題