Hi,

i have a model which defines a ImageField with
a path which exists in the media root.

Then i created a form which is bound to the Model
with Modelform.

All the fields in the Form are working as expected
despite the Image field.
I mean, i can choose an image, but it wont
upload to my path, nor would it throw
any errors.

Below is the code i use:

models.py:
class UserProfile(models.Model):
    ...
    pic = models.ImageField(upload_to=upload_path_avatar, blank=True, 
null=True,
                            verbose_name=_('picture:'))


forms.py:
class CompleteUser(ModelForm):      
   
    class Meta:
        model = UserProfile
        exclude = ('key', 'key_expires', 'user')


views.py:
def edit(request, name, template):  
 
    if request.method == 'POST':
        userprofile_form = CompleteUser(request.POST, request.FILES, 
instance=user_profile)
        user_form = UserForm(request.POST, instance=request.user)      
       
        if userprofile_form.is_valid() and user_form.is_valid() :
            userprofile_form.save()
            user_form.save()         
           
    else:  
        userprofile_form = CompleteUser(instance=user_profile)
        user_form = UserForm(instance=request.user)

    return render_to_response(template, {'name':name, 
'form':userprofile_form, 'user_form':user_form, }, RequestContext(request))


and the html file:
<form action="." method="post" enctype="multipart/form-data">
<li>{{ form.pic.label_tag }} {{ form.pic }}</li>   
<input type="submit" value="{% trans "Save" %}">



I've taken out the not so relevant parts.
The problem is i really dont know how to debug that
problem cause i got no error messages or something
like that. All it does is not working.


Greetings
Sven

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to