diff --git a/cocktail_list/__pycache__/admin.cpython-37.pyc b/cocktail_list/__pycache__/admin.cpython-37.pyc index 838f8ec..fbb4c47 100644 Binary files a/cocktail_list/__pycache__/admin.cpython-37.pyc and b/cocktail_list/__pycache__/admin.cpython-37.pyc differ diff --git a/cocktail_list/__pycache__/models.cpython-37.pyc b/cocktail_list/__pycache__/models.cpython-37.pyc index f0d7802..bbb351b 100644 Binary files a/cocktail_list/__pycache__/models.cpython-37.pyc and b/cocktail_list/__pycache__/models.cpython-37.pyc differ diff --git a/cocktail_list/admin.py b/cocktail_list/admin.py index 0b4fcc4..9f0fc8d 100644 --- a/cocktail_list/admin.py +++ b/cocktail_list/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Ingredienti,Cocktail,Strumenti,Bicchieri +from .models import Ingredienti,Cocktail,Strumenti,Bicchieri,Quantitá # Register your models here. class CocktailModel(admin.ModelAdmin): @@ -12,4 +12,5 @@ class CocktailModel(admin.ModelAdmin): admin.site.register(Ingredienti) admin.site.register(Strumenti) admin.site.register(Bicchieri) +admin.site.register(Quantitá) admin.site.register(Cocktail,CocktailModel) \ No newline at end of file diff --git a/cocktail_list/migrations/0008_auto_20200614_1225.py b/cocktail_list/migrations/0008_auto_20200614_1225.py new file mode 100644 index 0000000..2d99342 --- /dev/null +++ b/cocktail_list/migrations/0008_auto_20200614_1225.py @@ -0,0 +1,30 @@ +# Generated by Django 3.0.7 on 2020-06-14 12:25 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0007_auto_20200602_1728'), + ] + + operations = [ + migrations.CreateModel( + name='Quantitá', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.CharField(max_length=120)), + ], + ), + migrations.RemoveField( + model_name='ingredienti', + name='quantitá', + ), + migrations.AddField( + model_name='ingredienti', + name='quantitá_ingrediente', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cocktail_list.Quantitá'), + ), + ] diff --git a/cocktail_list/migrations/0009_auto_20200614_1236.py b/cocktail_list/migrations/0009_auto_20200614_1236.py new file mode 100644 index 0000000..69d1c66 --- /dev/null +++ b/cocktail_list/migrations/0009_auto_20200614_1236.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.7 on 2020-06-14 12:36 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('cocktail_list', '0008_auto_20200614_1225'), + ] + + operations = [ + migrations.AlterModelOptions( + name='quantitá', + options={'verbose_name': 'Quantitá', 'verbose_name_plural': 'Quantitá'}, + ), + migrations.AlterField( + model_name='ingredienti', + name='quantitá_ingrediente', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cocktail_list.Quantitá'), + ), + ] diff --git a/cocktail_list/migrations/__pycache__/0008_auto_20200614_1219.cpython-37.pyc b/cocktail_list/migrations/__pycache__/0008_auto_20200614_1219.cpython-37.pyc new file mode 100644 index 0000000..62be907 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0008_auto_20200614_1219.cpython-37.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0008_auto_20200614_1225.cpython-37.pyc b/cocktail_list/migrations/__pycache__/0008_auto_20200614_1225.cpython-37.pyc new file mode 100644 index 0000000..40dc547 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0008_auto_20200614_1225.cpython-37.pyc differ diff --git a/cocktail_list/migrations/__pycache__/0009_auto_20200614_1236.cpython-37.pyc b/cocktail_list/migrations/__pycache__/0009_auto_20200614_1236.cpython-37.pyc new file mode 100644 index 0000000..ef439c7 Binary files /dev/null and b/cocktail_list/migrations/__pycache__/0009_auto_20200614_1236.cpython-37.pyc differ diff --git a/cocktail_list/models.py b/cocktail_list/models.py index f025001..acf282d 100644 --- a/cocktail_list/models.py +++ b/cocktail_list/models.py @@ -2,42 +2,27 @@ from django.db import models from django.urls import reverse # Create your models here. +class Quantitá(models.Model): + quantity = models.CharField(max_length=120) + + def __str__(self): + return self.quantity + + class Meta: + verbose_name = "Quantitá" + verbose_name_plural = "Quantitá" + class Ingredienti(models.Model): ingrediente = models.CharField(max_length=100) - quantitá_scelta = [ - ('5ML', '5 ml'), - ('10ML', '10 ml'), - ('15ML', '15 ml'), - ('20ML', '20 ml'), - ('25ML', '25 ml'), - ('30ML', '30 ml'), - ('35ML', '35 ml'), - ('40ML', '40 ml'), - ('45ML', '45 ml'), - ('50ML', '50 ml'), - ('55ML', '55 ml'), - ('60ML', '60 ml'), - ('65ML', '65 ml'), - ('70ML', '70 ml'), - ('75ML', '75 ml'), - ('80ML', '80 ml'), - ('85ML', '85 ml'), - ('90ML', '90 ml'), - ('95ML', '95 ml'), - ('100ML', '100 ml'), - ('1 Goccia', '1 goccia'), - ('2 Gocce', '2 goccie'), - ('3 Gocce', '3 goccie'), - ('4 Gocce', '4 goccie'), - ('5 Gocce', '5 goccie'), - ('Cubetti', '3 Cubetti'), - ('Spruzzo', '1 Spruzzo'), - ] - quantitá = models.CharField(max_length=30,choices=quantitá_scelta,default="5ML") + quantitá_ingrediente = models.ForeignKey(Quantitá,on_delete=models.CASCADE) + + + def __repr__(self): + return self.quantitá_ingrediente.quantity + " " + self.ingrediente def __str__(self): - return self.ingrediente + return f"{self.ingrediente}" class Meta: verbose_name = "Ingrediente" diff --git a/cocktail_list/templates/cocktail.html b/cocktail_list/templates/cocktail.html index e462f68..ee8fa39 100644 --- a/cocktail_list/templates/cocktail.html +++ b/cocktail_list/templates/cocktail.html @@ -29,7 +29,7 @@ COCKTAIL | {{ cocktail.nome_cocktail }}

diff --git a/db.sqlite3 b/db.sqlite3 index 31a3a73..0e02200 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ