Q:

Is there any better way to add Nutrition Facts Model

I created a simple Blog of food recipes and I want to get a field like

Nutrition Facts: Fat : 20.4g Cholesterol : 2% Calories: 345

I created  models like
class Value(models.Model):
    ntr_value = models.FloatField()

class Nutrition(models.Model):
    name = models.CharField(max_length=20)
    value = models.ForeignKey(Value)
    publish_date = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return self.name
    
class Post(models.Model):
    catagory = models.ForeignKey(Catagory,on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    description = RichTextField()
    instruction = RichTextField()
    note_1 = RichTextField()
    note_2 = RichTextField()
    note_3 = RichTextField()
    note_4 = RichTextField()
    ingredients = RichTextField()
    dressing = RichTextField(blank=True,null=True)
    tags = models.ManyToManyField(Tag)
    **nutrition = models.ForeignKey(Nutrition)**

A:

Why not just have 3 fields in your Nutrition model?
fat_grams = models.FloatField()
cholesterol_percent = models.IntegerField()
calories = models.IntegerField()

If you wanted the flexibility of having more or less nutritional values, you may want to look into using a ManyToManyField value = models.ManyToMany(Value)

