On 27/09/2011 10:57, David wrote:
Hello

This is my view:

@login_required
@transaction.commit_on_success
def update_person(request):
     try:
         person_id = int(request.POST['person_id'])
     except KeyError:
         raise Http404
     person = Person.objects.select_related().get(pk=person_id)
     form = PersonForm(request.POST, request.FILES, instance=person,
prefix='person')
     if form.is_valid():
         form.save()
         return HttpResponse(serialize('json', (person,)),
mimetype="application/json")
     else:
         return HttpResponse(json.dumps(form.errors),
mimetype="application/json")

The above works, but the view never saves the image which is set to be
uploaded from my form.

My form tag does have enctype="multipart/form-data".

I have been reading through the docs, and I thought ModelForm's were
able to process image/file uploads with just form.save() ?

Thanks for any assistance.

Hi,

https://docs.djangoproject.com/en/dev/ref/models/fields/ and search FileField

--
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.

Reply via email to