adding food logging, phase 4

This commit is contained in:
Joren de Graaf
2026-10-03 21:07:30 +02:00
parent 03fcbcbafc
commit e7ddb0ea28
11 changed files with 245 additions and 4 deletions
+2 -1
View File
@@ -6,7 +6,7 @@ from .models import FoodLogEntry, FoodProduct, MealType
class ManualFoodForm(forms.ModelForm):
class Meta:
model = FoodProduct
fields = ('product_name', 'brand', 'base_unit', 'energy_kcal_100', 'carbohydrates_100', 'protein_100', 'fat_100', 'fibre_100', 'sugars_100', 'salt_100')
fields = ('product_name', 'brand', 'barcode', 'base_unit', 'energy_kcal_100', 'carbohydrates_100', 'protein_100', 'fat_100', 'fibre_100', 'sugars_100', 'salt_100')
labels = {
'energy_kcal_100': 'Calories per 100 g or ml',
'carbohydrates_100': 'Carbohydrates per 100 g or ml',
@@ -16,6 +16,7 @@ class ManualFoodForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['barcode'].required = False
for field in ('energy_kcal_100', 'carbohydrates_100', 'protein_100', 'fat_100'):
self.fields[field].required = True