I found two ways how to do it:
*) m2m_changed signal - this is the best way
*) save_model(self, request, obj, form, change) method for ModelAdmin -
obj has current relations, form contains the new relations
Martin
On Sun, 16 Jan 2011 19:33:09 +0100, Martin Tiršel <[email protected]>
wrote:
Hello,
I am using (only) django admin to insert data and have:
class ImageSize(models.Model):
...
class Image(models.Model):
size = models.ManyToManyField(ImageSize)
...
I need to save original image that have been uploaded (this is ok) and
then make resized copies depending on selected sizes. But my problem is,
I don't know where to put my resize code. I can not use save method on
Image class, because at this point, there are no ImageSize instances. So
I wanted to use ImageAdmin class but it seems that save_model method
behaves the same way - no related objects at this point. Is there a
point in admin, where I have all models completely saved and can do
custom code? Where is that point?
Thanks,
Martin
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to [email protected].
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.