1👍
What if you had three models? i.e.:
class Doctor(models.Model):
#some doctor specific fields
category = models.ForeignKey(Category)
class Category(models.Model):
name = models.CharField(max_length = 15)
color = models.ForeignKey(CategoryColor)
class CategoryColor(models.Model):
color = models.CharField(max_length = 7)
Then each Doctor would have a Category, and each Category would have one CategoryColor. If the Category already exists, you would use the existing one and its associated CategoryColor, otherwise it would create a new Category and corresponding CategoryColor.
👤Alex
Source:stackexchange.com