Hello,
-- You should start with the basics:
https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/
You are using request.FILES and that is for file upload, no file download. To upload a file to the server, you must have a <input type="file" ...> in your template, which you don't have.
To download files from the server to the browser (to the user computer), you should do:
https://docs.djangoproject.com/en/1.6/ref/contrib/staticfiles/
or, if the user uploaded the content:
https://docs.djangoproject.com/en/1.6/topics/files/
Hope this put you in the right direction.
Camilo
On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
Hello,
i wan to do download file of a checkbox ;
Please help me
this is my viewspy:
def export_selected_dataqq(request):
if request.method == 'POST':
_selected_action = request.FILES("_selected_action")
response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
response['Content-Disposition'] = 'attachment; filename=file.csv'
writer = csv.writer(response)
_selected_action = []
writer.writerow(_selected_action)
for obj in _selected_action:
row=[]
for field in User._meta.fields:
row.append(unicode(getattr(obj,field.name)).encode(" cp932"))
writer.writerow(row)
return response
this is mmy html:
<table >
<thead>
<tr>
<th>Check</th>
<th>名前</th>
<th>会社名</th>
<th>法人電話</th>
</tr>
</thead>
<tbody>
{% if articles.count > 0 %}
{% for user in articles %}
<tr>
<td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
<td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name }}</a></td>
<td >{{ user.company }}</td>
<td >{{ user.number }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% else %}
<p>None</p>
{% endif %}
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/129bfa86-8215-4bfe-9c7e-84a3fbef6017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment