How to recover ImageField value in Django when it returns an Error?
I have a form which contains an imagefield and some other fields.
my view looks like this:
def post_view(request):
def errorHandle(errors,form):
return render_to_response('post_form.html', {
'errors':errors,
'form' : form,
},context_instance=RequestContext(request))
if request.method == 'POST': # If the form has been submitted...
form = PostForm(request.POST, request.FILES) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
#save
else:
errors = form.errors
return errorHandle(errors,form)
else:
form = PostForm() # An unbound form
sucess = ''
return render_to_response('post_form.html', {
'form': form,
}, context_instance=RequestContext(request))
When errorHandle is called, it returns to the page with th开发者_开发问答e form, errors and the values entered except for the value entered on an ImageField.
tell me if you need to look at my form and model. thanks in advance.
I think it's normal.
Path of a client image is secure for a backend, so, it was not sent. It's an official HTTP feature.
精彩评论