我是Django 框架的新手,我试图生成一个链接以从Amazon S3下载文件。尝试加载模板页面时出现此错误:
Reverse for 'myapp.views.handles3downloads' with arguments '(u'README.md',)'
and keyword arguments '{}' not found.
网址.py
urlpatterns = patterns('',
url(r'^handles3downloads/(\d+)/$', handles3downloads),
)
视图.py
def handles3downloads(request, fname):
bucket_name = 'bucketname'
key = s.get_bucket(bucket_name).get_key(fname)
dfilename = key.get_contents_to_filename(fname)
wrapper = HttpResponse(file(dfilename))
response = HttpResponse(wrapper, content_type='text/plain')
response['Content-Length'] = os.path.getsize(dfilename)
return response
模板文件
<a href="{% url 'myapp.views.handles3downloads' sfile.linkUrl %}">{{sfile.linkUrl}}</a>
我查看了一些具有类似错误的解决方案,但对我没有帮助。谁能帮帮我。
提前谢谢