Hi. this is what it looks like.
<form action="{{function}}" method="POST" enctype="multipart/form- data" > On 26 Jan., 16:29, Brian Neal <bgn...@gmail.com> wrote: > On Jan 26, 9:16 am, 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 > > Hmm....You haven't shown your template. Do you have the correct > enctype attribute set on your <form> tag? > > http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-... > > If you forgot this, the form would still validate because your image > field has required=False. > > BN --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---