【问题标题】:django-secure crashing my sitedjango-secure 让我的网站崩溃
【发布时间】:2014-12-26 22:19:52
【问题描述】:

我有兴趣在我的整个 python django 项目中使用 https。我找到了this 解决方案,它看起来很有希望。我对我的 settings.py 进行了这些更改

SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 60
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_FRAME_DENY = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

MIDDLEWARE_CLASSES = (
# This middleware is for ensuring that all pages use https
'djangosecure.middleware.SecurityMiddleware',
...

INSTALLED_APPS = (
# for https
'djangosecure',
...

当我运行python manage.py checksecure 时,我得到的消息是All clear!,但是,当我部署到谷歌应用引擎时,我得到了这个错误:

File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-    1.5/django/core/handlers/base.py", line 51, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' %   (mw_module, e))
ImproperlyConfigured: Error importing middleware django-secure-    1.0.1.djangosecure.middleware: "No module named django-secure-   1.0.1.djangosecure.middleware"

我做错了什么?

【问题讨论】:

  • 我不太喜欢回溯中django-secure-1.0.1.djangosecure.middleware 之间的间距。
  • 对不起,@alecxe,间距不应该在那里。我刚刚复制并粘贴了错误。

标签: python django google-app-engine web https


【解决方案1】:

Google App 引擎环境中没有安装名为“django-secure”的模块。您需要将此模块提供给您在 Google App 引擎中的应用程序。

Here is a question and answer which gives instructions on how to do this.

【讨论】:

  • 那么,当我将应用部署到谷歌应用引擎时,这还不够吗?
  • 正确!这就是错误告诉你的。看起来 Google App Engine 无法正确安装 Python 模块,因此您必须在项目中包含整个模块。
  • 好的,太好了。抱歉,我对此有点陌生。我下载了整个库并使用了pip install django-secure。我查看了您提供的链接,但我认为我需要再次查看它,因为我仍然不清楚如何确保 google 应用引擎拥有所需的一切。
  • 您使用的是什么操作系统?视窗?苹果电脑? Linux?
  • 好的,所以也许可以尝试使用这个答案来查找已安装模块的位置:stackoverflow.com/questions/122327/…。然后你可以将整个django-secure文件夹复制到你的项目目录中。
猜你喜欢
  • 2017-12-13
  • 2018-12-11
  • 1970-01-01
  • 1970-01-01
  • 2012-12-27
  • 1970-01-01
  • 1970-01-01
  • 2014-01-13
  • 1970-01-01
相关资源
最近更新 更多