Cocktail-DB/cocktail_list/models.py

63 lines
1.7 KiB
Python
Raw Normal View History

2020-05-25 09:49:36 +00:00
from django.db import models
from django.urls import reverse
# Create your models here.
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'),
2020-05-25 09:49:36 +00:00
('Cubetti', '3 Cubetti'),
('Spruzzo', '1 Spruzzo'),
2020-05-25 09:49:36 +00:00
]
quantitá = models.CharField(max_length=30,choices=quantitá_scelta,default="5ML")
def __str__(self):
return self.ingrediente
class Meta:
verbose_name = "Ingrediente"
verbose_name_plural = "Ingredienti"
class Cocktail(models.Model):
ingredienti = models.ManyToManyField(Ingredienti)
nome_cocktail = models.CharField(max_length=120)
preparazione = models.TextField()
storia = models.TextField()
curiositá = models.TextField()
immagine_cocktail = models.ImageField(upload_to="cocktail_img",blank=True,null=True)
def __str__(self):
return f"{self.nome_cocktail}"
2020-05-25 09:49:36 +00:00
def get_absolute_url(self):
return reverse('cocktail', kwargs={'nome_cocktail': self.nome_cocktail})
class Meta:
verbose_name = "Cocktail"
verbose_name_plural = "Cocktails"