hello:
I could not import csv to SnetOS from local pc, please tell me
this is my views.py file :
def import_csv(request):
upload_filename = 'csvfile'
if request.method == 'POST' and
request.FILES.has_key('upload_filename'):
csv_file = request.FILES['csv_file']
response = HttpResponse(mimetype='application/vnd.ms-excel;
charset=UTF-8')
response['Content-Disposition'] = 'attachment; filename=file.csv'
reader = csv.reader(response)
reader = csv.reader(csv_file)
for row in reader:
tmp = User.objects.create()
tmp.UserID = row[0]
tmp.user_name = row[1]
tmp.first_kana = row[2]
tmp.last_kana = row[3]
tmp.save()
csv_file.close()
return HttpResponseRedirect('/memo/all')
else:
tmp = User.objects.all()
args = {}
args.update(csrf(request))
args['tmp'] = tmp
return render_to_response('importcsv.html', args)
this is my html:
{% extends "base.html" %}
{% block content %}
<div>
<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_table }}
<input type="file" name="csvfile">
<input type="submit" value="import" id="Save">
</form>
</div>
{% endblock %}
--
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 [email protected].
To post to this group, send email to [email protected].
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/235e6f94-846f-46f7-a987-f3c7bb8e545a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.