为什么这个 Django 插件不起作用?
https://github.com/sunlightlabs/django-mediasync/
媒体同步到 S3,但它不会将我的模板中的 {% MEDIA_URL %} 更改为 s3 url(当我投入生产时)
我遵循了所有说明。这是我的设置.py。
MEDIASYNC = {
'AWS_KEY': AWS_ACCESSKEY,
'AWS_SECRET': AWS_SECRETKEY,
'AWS_BUCKET': "happy_media",
'BACKEND': 'mediasync.backends.s3',
'SERVE_REMOTE': True,
'AWS_BUCKET_CNAME': True,
'DOCTYPE': 'html4',
'USE_SSL': False,
'CACHE_BUSTER': 1234,
}
我还将其添加到了 urls.py
from django.template import add_to_builtins
add_to_builtins('mediasync.templatetags.media')
我也有:
'django.core.context_processors.media' to my context processors in settings.py
https://github.com/sunlightlabs/django-mediasync/
The media syncs to S3, but it doesn't change the {% MEDIA_URL %} to the s3 url in my template (when I go to production)
I followed all the instructions. Here's my settings.py.
MEDIASYNC = {
'AWS_KEY': AWS_ACCESSKEY,
'AWS_SECRET': AWS_SECRETKEY,
'AWS_BUCKET': "happy_media",
'BACKEND': 'mediasync.backends.s3',
'SERVE_REMOTE': True,
'AWS_BUCKET_CNAME': True,
'DOCTYPE': 'html4',
'USE_SSL': False,
'CACHE_BUSTER': 1234,
}
I also added this to the urls.py
from django.template import add_to_builtins
add_to_builtins('mediasync.templatetags.media')
I also have:
'django.core.context_processors.media' to my context processors in settings.py
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将“django.core.context_processors.media”包含到 settings.py 中的上下文处理器列表中。我认为这就是公开 MEDIA_URL 并使其在模板中可见的原因。
Try including 'django.core.context_processors.media' to your list of context processors in settings.py. I think that's what exposes MEDIA_URL and makes it visible in templates.
你有这个模板上下文处理器吗?
Do you have this template contex processor ?
解决了。
我只是这样做了:
请注意,它不同于:
Solved.
I simply did this:
Notice that it's different from: