Thanks for helping.
I have a view that allows me to upload a csv file and to read it. I want this file's data to be put in one of my template (and hence on a webpage). My view looks like this:
@login_required
def uploadFunc(request, username):
user = get_object_or_404(User, username=username)
if request.method == 'GET':
return render_to_response('upload.html',{'user':user},context_instance=RequestContext(request))
elif request.method == 'POST':
with open('penguins.csv', 'rb') as f:
reader = csv.reader(f)
for m in reader:
print m
return HttpResponseRedirect("/")
As you can see from
print m
return HttpResponseRedirect("/")
I print the data extracted (it gets printed to terminal, but not a webpage), and then redirect the upload page to my home page where a table out of the penguin.csv (don't laugh at the name! I know:)) should be constructed. Thing is I do not understand (or know) how do I let my template index.html to know that it is that file that should be put in that table.
Sorry for a lot of talk, if it is confusing feel free to ask questions.
Thanks again, blargie-bla