Here's my simple form:
<pre>
class AvatarForm(forms.Form):
"""Form for uploading avatars"""
avatar = forms.ImageField()
</pre>
and here's the view that processes it:
<pre>
def avatar(request):
"""View to process avatar uploads"""
import pdb; pdb.set_trace()
if request.method == 'POST':
form = AvatarForm(request.POST, request.FILES)
assert form.is_valid(), request.FILES
if form.is_valid():
handle_avatar_upload(request.FILES['avatar'])
return HttpResponseRedirect('/')
else:
form = AvatarForm()
return render_to_response('avatar.html',
{'form': form})
</pre>
The problem is the form is never valid with error message "No file was
submitted. Check the encoding type on the form." And the encoding of
the form is multipart/form-data.
pdb shows request.FILES['avata'] to contain a proper image file.
I try stepping into form.is_valid() call but pdb just informs me that
the call is being made to a file, but it never offers to trace through
the file, when I come to this:
Call
> c:\dev\django-trunk\django\newforms\forms.py(112)is_valid()
I say "step" and "list" which results in EOF output. Anybody knows why
my pdb doesn't show any of Django's internal sources for me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---