On Jan 26, 3:16 pm, PeteDK <petermoel...@gmail.com> wrote:
> Hi there :)
>
> first the code:
>
> forms:
> class ProfileForm(forms.Form):
>         ...
>         image = forms.ImageField(required = False)
>
> models:
> class Profile(models.Model):
>         user = models.ForeignKey(User, unique=True)
>         ....
>         image = models.ImageField(upload_to="images/", blank=True, null=True)
>
> views:
>                         formP = ProfileForm(request.POST,request.FILES)
>                         if formP.is_valid():
>
>                                 profile = user.get_profile()
>                                 image = formP.cleaned_data['image']
>                                 if image:
>                                         print "image test"
>                                         
> profile.save_image_file(image.filename, image.content,save=False)
>                                 profile.save()
>
> I have installed PIL and i don't get any error messages of any sort.
> however if i try to print image it just prints "None". and "image
> test" never gets printed.
> I have also set media root and URL and all that in my settings file.
>
> I could really use some help here :-(
>
> Maybe i have to import something, but somehow i think that i'm not
> just not getting my image file back.
> Oh and i have tried .png aswell as .jpeg

Have you set enctype="multipart/form-data" on the form tag in your
template?
http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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