1 from django.contrib.auth.models import User
2 from django.db import models
4 class Food(models.Model):
5 name = models.CharField(max_length=64)
6 brand = models.CharField(max_length=64)
7 calories = models.PositiveIntegerField()
10 return '{} ({})'.format(self.name, self.brand)
12 WEIGHT_UNITS_CHOICES = (
17 class WeightRecord(models.Model):
18 user = models.ForeignKey(User, on_delete=models.CASCADE)
19 weight = models.PositiveIntegerField()
20 units = models.CharField(max_length=3, choices=WEIGHT_UNITS_CHOICES)
23 return '{}: {}{}'.format(