Dear All,

I am trying to use the ImageField in my model, and use get_thumbnail in the 
forms.py. 
The problem is:
If I don't use get_thumbnail, it works well. The image was uploaded 
successfully and the thumbnail shows on the admin page. It works well.
However, If I try to use the get_thumbnail to rescale the image, it fails. 

IOError at /admin/labcv/person/2/

[Errno 2] No such file or directory: u'/root/django/mysite_new/media/www.jpg'

Request Method:POSTRequest 
URL:http://192.168.1.1:8000/admin/labcv/person/2/Django 
Version:1.4Exception Type:IOErrorException Value:

[Errno 2] No such file or directory: u'/root/django/mysite_new/media/www.jpg'







Here is my code snippet:

models.py
Class Person(models.Model):
   ........
  photo = *ImageField*(upload_to = 'images/', null=True, blank=True)
   ......

forms.py

class PersonAdminForm(ModelForm):
    class Meta:
        model = Person

    def clean_photo(self):
        image = self.cleaned_data.get('photo', False)
        if image:
            *t = get_thumbnail(image, "400x400")   # I add this additional 
line to test get_thumbnail.  If I remove this line, it works well. 
*            return image
        else:
            raise ValidationError("You must upload your photo")


admin.py

class PersonAdmin(*AdminImageMixin*, admin.ModelAdmin):
    form = PersonAdminForm
    inlines = [SectionInline]


settings.py

THUMBNAIL_DEBUG = True

MEDIA_ROOT = SITE_ROOT + '/../media/'
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'

my directory tree is as follows:
.
├── labcv
│   ├── admin.py
│   ├── admin.pyc
│   ├── forms.py
│   ├── forms.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── static
│   │   ├── images
│   │   │   └── hi.png
│   │   └── scripts
│   │       └── functions.js
│   ├── templatetags
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── labcv_tags.py
│   │   └── labcv_tags.pyc
│   ├── tests.py
│   ├── views.py
│   └── views.pyc
├── manage.py
├── media
│   ├── cache
│   │   ├── 0f
│   │   │   └── c9
│   │   │       └── 0fc9272233811b5b630f568c452a7827.jpg
│   │   ├── 17
│   │   │   └── 11
│   │   │       └── 1711bafea9d8da8572cfe3f3be01506b.jpg
│   │   ├── 26
│   │   │   └── ae
│   │   │       └── 26aec38ff13d7db7aa9ba0b954a1a10b.jpg
│   │   ├── 81
│   │   │   └── ac
│   │   │       └── 81ac76c08c643711916b282e9bbee43b.jpg
│   │   └── d8
│   │       └── e5
│   │           └── d8e556ad6da2c24ff464a40ae671fd13.jpg
│   └── images
│       ├── aaaaaaaaa.JPG
│       ├── aaaaaaaaa.png
├── mysite
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── logfile
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
└── mytemplates
    ├── admin
    │   ├── base_site.html
    │   └── labcv
    │       ├── person
    │       └── section
    │           └── change_form.html.bad
    └── labcv
        ├── detail.html
        ├── index.html
        └── items.html

Please help! 
any suggestions? 
any links for the corresponding knowledge? 

Thanks!!








-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dj2t8cHevWEJ.
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