I have a model that can be attached to a variety of different models, based on the value of a column. Is there any way to map this relationship in Django? If not, is there a way to automatically do post-fetch processing where I could populate it?
Here is a example: class Note(models.Model): owner_id = models.IntegerField() #this is the FK of the related object owner_type = models.CharField(max_length=40) # this can either be "Account" or "Ticket" note = models.TextField() class Account(models.Model) name = models.CharField(max_length=40) ... class Ticket(models.Model) subject = models.CharField(max_length=120) ... So basically, we can attach Notes to either Account or Ticket. The "owner_id" field will be the primary key of the object being attached to. The "owner_type" will be either "Account" or "Ticket". When retrieving an Account, I want to also return all the Notes associated with it. I don't care about going the other direction in the relationship Is there any way to do this with the Django mappings? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---