Hey,

I've just upgraded my Django to the trunk and noticed some code I need
to change. I've got a form that uploads images, looks like Django
throws up an error if the file is not an image, which is nice but I
also need to check if the image is too big/small. Here is the code:

class SettingsImageForm(forms.Form):
        avatar = forms.ImageField()

        def clean_avatar(self):
                size = len(self.cleaned_data['avatar'].content)
                if size > 500 * 1024:
                        raise forms.ValidationError('Size exceeded allowable 
limit')
                return self.cleaned_data['avatar']

So in my views.py I just do this:

if form.is_valid():

Which throws up this error:

'InMemoryUploadedFile' object has no attribute 'content'

Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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