Hey, this looks like the same problem I had earlier. The gotcha was that I needed enctype="multipart/form-data" in my form tag, like <form enctype="multipart/form-data" action="" method="post">
Hope this isn't too late! Aaron On Mar 9, 5:34 am, Marek Wawrzyczek <mwawrzyc...@gmail.com> wrote: > Hi, > > I've got the code like this: > > class Photo(models.Model): > image = models.ImageField(upload_to='photos') > > class PhotoForm(ModelForm): > class Meta: > model = Photo > > View function fragment: > > if request.method == 'POST': > post = request.POST.copy() > print 'post: %s' % post > photoForm = PhotoForm(post) > if photoForm.is_valid(): > print 'photoForm valid' > photoForm.save() > else: > print 'photo form is invalid' > return render_to_response(template_name, {'photoForm' : photoForm}) > else: > photoForm = PhotoForm() > return render_to_response(template_name, { 'photoForm' : photoForm}) > > Template fragment: > > <form id="photoForm" method="POST" action="."> > <ul class="errorlist"> > </ul> > {{photoForm.non_field_errors}} > {{ photoForm.as_p }} > <input type="submit" value="dodaj zdjecie"/> > </form> > > Through the admin interface, I can add new photos, but when I try to add > it through the page, then the > "This field is required." message is posted, and the output on the > console is: > > post: <QueryDict: {u'image': [u'abc.gif']}> > photo form is invalid > > When I try to use FileField it works the same. How can I slove this > problem ? > > Regards, > Marek --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---