import re from decimal import Decimal from django.db import migrations PATTERNS = ( ('water', r'water'), ('juice', r'juice|sap|limonade|lemonade'), ('milk', r'milk|melk|chocolademelk'), ('coffee', r'coffee|koffie|espresso|cappuccino|latte'), ('tea', r'tea|thee'), ('smoothie', r'smoothie|shake'), ('other_drink', r'soda|cola|drink|drank|bier|beer|wine|wijn'), ) def backfill_food_drinks(apps, schema_editor): Entry = apps.get_model('food', 'FoodLogEntry') for entry in Entry.objects.filter(unit='ml', hydration_source='').iterator(): name = entry.product_name_snapshot.casefold() kind = next((kind for kind, words in PATTERNS if re.search(rf'(?