Added constraints to many to many tables

This commit is contained in:
Jim Martens 2020-02-19 13:37:18 +01:00
parent e44c08ca09
commit 5b2fd176da
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# Generated by Django 3.0.3 on 2020-02-19 12:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('food_planner', '0001_initial'),
]
operations = [
migrations.AlterUniqueTogether(
name='storedingredient',
unique_together={('pantry', 'ingredient')},
),
migrations.AlterUniqueTogether(
name='usedingredient',
unique_together={('recipe', 'ingredient')},
),
migrations.AlterUniqueTogether(
name='usedkitchenutility',
unique_together={('recipe', 'kitchen_utility')},
),
]

View File

@ -122,6 +122,7 @@ class UsedKitchenUtility(models.Model):
default=1)
class Meta:
unique_together = ['recipe', 'kitchen_utility']
verbose_name = _('Used kitchen utility')
verbose_name_plural = _('Used kitchen utilities')
@ -134,6 +135,7 @@ class UsedIngredient(models.Model):
unit = models.CharField(_('Unit for amount'), max_length=10, choices=MEASUREMENT_UNITS)
class Meta:
unique_together = ['recipe', 'ingredient']
verbose_name = _('Used ingredient')
verbose_name_plural = _('Used ingredients')
@ -190,6 +192,7 @@ class StoredIngredient(models.Model):
choices=MEASUREMENT_UNITS)
class Meta:
unique_together = ['pantry', 'ingredient']
verbose_name = _('Stored ingredient')
verbose_name_plural = _('Stored ingredients')