Sunday, March 30, 2014

Django python checkbox

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/c8b66947-b791-47bf-8000-4f2865351a03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment