python - Downloading files from amazon s3 using django -


i new django framework, trying generate link download files amazon s3. got error when tried load template page:

reverse 'myapp.views.handles3downloads' arguments '(u'readme.md',)' , keyword arguments '{}' not found. 

urls.py

urlpatterns = patterns('',     url(r'^handles3downloads/(\d+)/$', handles3downloads), ) 

views.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 

template file

<a href="{% url 'myapp.views.handles3downloads' sfile.linkurl %}">{{sfile.linkurl}}</a> 

i looked @ of solutions similar errors didn't me. can me out please.

advance thanks

your regular expression in urls.py file seems wrong. try using instead:

url(r'^handles3downloads/(\w+)/$', handles3downloads), 

you're passing parameter string view, , regex matching integers.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -