[Answer]-What's the best way to create models for this situation in django?

1👍

Try unique_together.

class MasterService(models.Model):
    master = models.ForeignKey(Master)
    service = models.ForeignKey(Service)
    price = models.PositiveIntegerField(blank=True)

    class Meta:
        unique_together = ('master', 'service')

This constraint will be enforced at the database level, so it won’t be possible to associate a service with a master more than once. See the docs.

Leave a comment