On 16-10-2005, at 20:43, Bo Shi wrote:

Moving the rename logic to _pre_save() would be the best way of doing
things but I have a problem where I rename the uploaded file into one
based on it's primary key.  While in _pre_save(), self.id is None, so
is there a way to access the value that will become the primary key?

Well, I never (yet) run in this kind of a problem. Generally I always use some kind of SlugField as a secondary primary key (unique) that gives me a pretty (and human readable) URLs. It's not possible to know under witch id record will be saved.

You can try to move rename logic into _post_save(). IIRC when you hit _post_save object is already in db so self.id will have a value. After renaming file and updating image field you must again save() object.

---
Nebojša Đorđević - nesh
Studio Quattro - Niš - SCG

http://djnesh.blogspot.com/  |  http://djnesh-django.blogspot.com/
Registered Linux User 282159 [http://counter.li.org]



Reply via email to