from django.shortcuts import render
...
def upload_file(request):
...
return render('upload_form.html', {'form': form})
heya,I was previously using the following to render a form:from django.shortcuts import render_to_response, RequestContext...def upload_file(request):...return render_to_response('upload_form.html', {'form': form}, context_instance=RequestContext(request))I can confirm that this works fine, form was rendered perfectly fine.However, I read that render() is now the bee-knees...lol (http://stackoverflow.com/questions/5154358/django-what-is-the-difference-between-render-render-to-response-and-direct), so I thought I'd switch to that:from django.shortcuts import render
...
def upload_file(request):
...
return render('upload_form.html', {'form': form})However, when I try to do that, I get an error:
<snip>
Exception Type: AttributeError at /upload/Exception Value: 'str' object has no attribute 'META'Any idea from the above why this might be happening?Thanks,Victor
> from django.shortcuts import render
> ...
> def upload_file(request):
> ...
> return render('upload_form.html', {'form': form})
"render" requires as its first argument the request object supplied to your view function. So, your example should be:
def upload_file(request):
...
return render(request, 'upload_form.html', {'form': form})
Sebastian.