Related objects save after `host`. So insertion into M2M table happens after
save method of host object has executed. In your example - after
`Ticket.save`


On Mon, Nov 17, 2008 at 14:49, Marco Minutoli <[EMAIL PROTECTED]>wrote:

>
> I have this model:
>
> class Ticket(models.Model):
>    ## ForeignKey
>    project = models.ForeignKey (
>        'Project',
>        null=True,
>        blank=True,
>        verbose_name="Project",
>    )
>    submitter = models.ForeignKey (
>        User,
>        related_name="submitter",
>        verbose_name="Submitter",
>    )
>    assigned_to = models.ManyToManyField (
>        User,
>        blank=True,
>        null=True,
>        verbose_name="Assigned to",
>    )
>
>
> I would like to send an email to all 'assigned_to' when a ticket is
> created. So i've override the Ticket Model's save method:
>
>    def save(self):
>        super(Ticket, self).save()
>        print self.assigned_to.all()
>        print self.submitter.username
>
> But the "self.assigned_to.all()" is always empty, whilst
> self.submitter.username is correct.
> P.S The assigned_to is correctly insert into the db.
> Why?
>
> Sorry for my bad English..
> Marco.
>
> >
>

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