我有一个django(1.6.5)项目,我正在使用django-configurations(0.8)包,我试图通过以下方式在settings.py文件中设置环境变量的STATIC_URL:
from configurations import Configuration, values
BUCKET_NAME = values.SecretValue()
STATIC_URL = 'https://s3.amazonaws.com/%s/' % BUCKET_NAME
但是STATIC_URL设置为:
'https://s3.amazonaws.com/<Value default:None>'
无效或有意。我也设置了正确的环境变量:DJANGO_BUCKET_NAME ='thekey'
任何帮助将不胜感激
答案 0 :(得分:3)
我查看了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'),)
答案 1 :(得分:2)
问题是django-configurations中__repr__
的{{1}}方法。
他们已经修复了这个问题,但没有更新pckage版本,所以pypy仍然引用了错误的版本。
解决方法是将Value
设置为:
'https://s3.amazonaws.com/%s/' % (AWS_STORAGE_BUCKET_NAME.setup('AWS_STORAGE_BUCKET_NAME'),)
来源:https://github.com/burhan/cookiecutter-django/commit/c8ee217dd72ec29ccea4f683d83ca7438247461c