I'm trying to generate a slug for a model, based on the contents of many2many field, but my approaches so far don't seem to work. I'd be grateful if anyone point me towards a better approach. Here's a simple example of what I'm doing:
class Item(models.Model): name = models.CharField() def __unicode__(self): return self.name class Ticket(models.Model) items = models.ManyToManyField(Item) slug = models.CharField(editable=False) def update_ticket_slug(**kwargs): instance = kwargs['instance'] # concatenate the names of all the items into a string instance.slug = ", ".join([str(i) for i in instance.items.all()]) instance.save() post_save.connect(update_ticket_slug, sender=Ticket) The post_save signal is correctly fired, but instance.items.all() always returns an empty set. I guess the m2m relation hasn't been saved yet. Question: how do I do what I'm trying to do above? Is there a different approach I can use? --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---