Aggiunta Classe Quantitá
parent
bd2622b7a0
commit
6ede5f03fd
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Ingredienti,Cocktail,Strumenti,Bicchieri
|
from .models import Ingredienti,Cocktail,Strumenti,Bicchieri,Quantitá
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
class CocktailModel(admin.ModelAdmin):
|
class CocktailModel(admin.ModelAdmin):
|
||||||
|
@ -12,4 +12,5 @@ class CocktailModel(admin.ModelAdmin):
|
||||||
admin.site.register(Ingredienti)
|
admin.site.register(Ingredienti)
|
||||||
admin.site.register(Strumenti)
|
admin.site.register(Strumenti)
|
||||||
admin.site.register(Bicchieri)
|
admin.site.register(Bicchieri)
|
||||||
|
admin.site.register(Quantitá)
|
||||||
admin.site.register(Cocktail,CocktailModel)
|
admin.site.register(Cocktail,CocktailModel)
|
|
@ -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á'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -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á'),
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,42 +2,27 @@ from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
# Create your models here.
|
# 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):
|
class Ingredienti(models.Model):
|
||||||
ingrediente = models.CharField(max_length=100)
|
ingrediente = models.CharField(max_length=100)
|
||||||
quantitá_scelta = [
|
quantitá_ingrediente = models.ForeignKey(Quantitá,on_delete=models.CASCADE)
|
||||||
('5ML', '5 ml'),
|
|
||||||
('10ML', '10 ml'),
|
|
||||||
('15ML', '15 ml'),
|
def __repr__(self):
|
||||||
('20ML', '20 ml'),
|
return self.quantitá_ingrediente.quantity + " " + self.ingrediente
|
||||||
('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")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.ingrediente
|
return f"{self.ingrediente}"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Ingrediente"
|
verbose_name = "Ingrediente"
|
||||||
|
|
|
@ -29,7 +29,7 @@ COCKTAIL | {{ cocktail.nome_cocktail }}
|
||||||
<hr>
|
<hr>
|
||||||
<ul>
|
<ul>
|
||||||
{% for ingredienti in cocktail.ingredienti.all %}
|
{% for ingredienti in cocktail.ingredienti.all %}
|
||||||
<li class="text-on-body">{{ ingredienti.ingrediente }}</li>
|
<li class="text-on-body">{{ ingredienti.quantitá_ingrediente }} {{ ingredienti.ingrediente }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Loading…
Reference in New Issue