Hi Darryl and Tane,

>
> [untested with Many2Many, but should work, it works for ForeignKeys]

Actually, the approach below won't work for M2M even though it does
for FKs.

> In your Entry save() method call the save method of each of your related
> categories after you do your super().save()
>
> {{{
> class Entry(models.Model):
>     ...
>     def save(self):
>         if not self.slug:
>             self.slug = slugify(self.title)
>         super(Entry, self).save()
>         for category in self.categories:
>             category.save()
>     ...

Entry.save() is called /before/ the M2M category table is updated by
Django. That means this save()  can not iterate over Categories. This
will work (albeit, incorrectly) when an existing Entry is being
updated because it will already have some old M2M categories but it
won't work when creating a new Entry as self.categories would not be
available during this save().


--~--~---------~--~----~------------~-------~--~----~
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