I've created below models as a working solution for an app where I need 
multiple unique combinations of A and B in C:

class A(models.Model):
    title = models.CharField(max_length=30)
class B(models.Model):
    title = models.CharField(max_length=255)
    a = models.ManyToManyField(A)
class C(models.Model):
    title = models.CharField()
    property1 = models.CharField()
class A_B_C(models.Model):
    a = models.ForeignKey(A)
    b = models.ForeignKey(B)
    c = models.ForeignKey(C)
    class Meta:
        unique_together = ('a', 'b', 'c')

I was avoiding to create A_B_C explicitly and maintain it within relations. 
I would like to know if this solution would be efficient or is there 
another Django way to do things?
StackOverflow link: 
http://stackoverflow.com/questions/34787606/django-complex-relationship

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4310ca4-fd8f-45e4-804c-406cfba0368a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to