ImageField and built-in filesystem storage

20 views
Skip to first unread message

Xavier Ordoquy

unread,
Mar 2, 2010, 4:44:17 AM3/2/10
to django...@googlegroups.com
Hi,

I'm currently working on Django for a website on a legacy database but I'm facing an issue on getting ImageField working with it in the admin.

In the database images are stored as a simple file name, because they have several size precomputed on different directories.
So basically, I need to:
- save the filename - and only the filename - the database
- save the file to a given location and resize it to different size

I tried different ways to get this working but none did work in order to get the correct filename in the database.

First I edited the ImageField.name when model is saved but the name gets overwritten when saving the model.

Then I gave the build-in filesystem storage but it didn't work better.
http://docs.djangoproject.com/en/1.1/topics/files/#the-built-in-filesystem-storage-class doesn't mention you need upload_to
However, whenever upload_to is set, it overrides the storage location which seems to contradict ticket #8918.

Has someone already solved a similar issue ?

Xavier.

thanos

unread,
Mar 2, 2010, 1:50:58 PM3/2/10
to Django users
You take a look at how I did things in

http://code.google.com/p/django-googledata/

Thanos

On Mar 2, 4:44 am, Xavier Ordoquy <xordo...@linovia.com> wrote:
> Hi,
>
> I'm currently working on Django for a website on a legacy database but I'm facing an issue on getting ImageField working with it in the admin.
>
> In the database images are stored as a simple file name, because they have several size precomputed on different directories.
> So basically, I need to:
>  - save the filename - and only the filename - the database
>  - save the file to a given location and resize it to different size
>
> I tried different ways to get this working but none did work in order to get the correct filename in the database.
>
> First I edited the ImageField.name when model is saved but the name gets overwritten when saving the model.
>

> Then I gave the build-in filesystem storage but it didn't work better.http://docs.djangoproject.com/en/1.1/topics/files/#the-built-in-files...doesn't mention you need upload_to

Reply all
Reply to author
Forward
0 new messages