1

ロケールとしてフォーマットされた JSON によって、日時のリストをクライアントに送信しようとしています。

したがって、主な問題は実際にクライアントのロケールを取得しようとすることです。

私は使用しようとしましたrequest.META['LC_TIME'](日付と時刻のクライアントの優先ロケールのようです)

このキーは開発中ですが、本番環境ではありません。

KeyError: 'LC_TIME'

どのように説明できますか?私は正しい軌道に乗っていますか?

4

1 に答える 1

1

First, let's determine what you mean under 'Production environment'. Under DEV environment, the browser connects directly to the Django web server, and all HTTP headers are sent directly to it. In PRODUCTION, you usually have a proxy. This could be an nginx or other similar software. Their main purpose is to redirect, while performing some checks. You should check in your PRODUCTION environment, what is the actual setup of the proxy(if any), and if it strips any HTTP header sent from client(which seems like a valid reason for the error you get).

Besides the configuration issues, it is recommended to use a default value:

user_lc_time = request.META.get('LC_TIME', default_lc_time)
于 2012-06-09T13:07:36.067 に答える