[Answer]-Going back and forth in django relations

1👍

You in fact have a many to many relationship between Peri and Tooth thru the PeriTask model. The simplest thing to do would be to explicitely declare this relationship (in either Tooth or Peri) so the orm knows about it an add the appropriate descriptor to your models, cf https://docs.djangoproject.com/en/1.7/topics/db/models/#intermediary-manytomany :

class Tooth(models.Model):
    #fields
    customer = models.ForeignKey(Customer)
    peris = models.ManyToManyField("Peri", through="PeriTask")

Then you have access to a given peri‘s related theeth with peri.tooth.all().

Leave a comment