Django-Configurations导致我的STATIC_URL无效 [英] Django-Configurations is causing my STATIC_URL to be invalid

查看:179
本文介绍了Django-Configurations导致我的STATIC_URL无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个django(1.6.5)项目,我使用的是 django-configurations(0.8)包,我试图通过执行以下操作,将settings_file文件中的STATIC_URL设置为环境变量:

  from配置导入配置,值
BUCKET_NAME = values.SecretValue()
STATIC_URL ='https://s3.amazonaws.com/%s/'%BUCKET_NAME

但是STATIC_URL设置为:

  https://s3.amazonaws.com/<Value默认值:无>'

哪个不是有效或意图我也有正确的环境变量:DJANGO_BUCKET_NAME ='thekey'



任何帮助将不胜感激

解决方案

我查看了django cookie cutter的问题,发现这个解决方案:



https://github.com/burhan/cookiecutter-django/commit/c8ee217dd72ec29ccea4f683d83ca7438247461c



其中告诉我要切换:

  STATIC_URL ='https://s3.amazonaws.com/%s/' %AWS_STORAGE_BUCKET_NAME 

至:

  STATIC_URL ='https://s3.amazonaws.com/%s/'%(AWS_STORAGE_BUCKET_NAME.setup('DJANGO_AWS_STORAGE_BUCKET_NAME'),)


I have a django(1.6.5) project and I am using the django-configurations(0.8) package and I am trying to set the STATIC_URL in the settings.py file with an environment variable by doing:

from configurations import Configuration, values
BUCKET_NAME = values.SecretValue()
STATIC_URL = 'https://s3.amazonaws.com/%s/' % BUCKET_NAME

But the STATIC_URL is set to:

'https://s3.amazonaws.com/<Value default:None>'

which is not valid or intended. I have the correct environment variable set too: DJANGO_BUCKET_NAME='thekey'

Any help would be appreciated

解决方案

I looked at issues with the django cookie cutter and found this solution:

https://github.com/burhan/cookiecutter-django/commit/c8ee217dd72ec29ccea4f683d83ca7438247461c

Which told me to switch:

STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME

to:

STATIC_URL = 'https://s3.amazonaws.com/%s/' % (AWS_STORAGE_BUCKET_NAME.setup('DJANGO_AWS_STORAGE_BUCKET_NAME'),)

这篇关于Django-Configurations导致我的STATIC_URL无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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