Trying to use a very simple form to upload a file into a new class instance. I am expecting to have both files in request.FILES
but it\'s empty. I am on the bun
I think your troubles may lie in assigning data to a form without first verifying the the request is POST
@login_required
def create_map(request, form_class=WayfinderMapForm, template_name="wayfinder/map create.html"):
if request.method=='POST':
wayfinder_map_form = form_class(request.user, data=request.POST, files=request.FILES)
if wayfinder_map_form.is_valid():
#save your data
return HttpResponseRedirect(wayfinder_map.get_absolute_url())
else:
wayfinder_map_form=form_class(request.user)
return render_to_response(template_name, {"wayfinder_map_form": wayfinder_map_form,}, context_instance=RequestContext(request))