Cocktail-DB/cocktail_list/models.py

65 lines
1.6 KiB
Python

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'),
('1Goccia', '1 goccia'),
('2Gocce', '2 goccie'),
('3Gocce', '3 goccie'),
('4Gocce', '4 goccie'),
('5Gocce', '5 goccie'),
('Cubetti', '3 Cubetti'),
]
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 self.nome_cocktail
def get_absolute_url(self):
return reverse('cocktail', kwargs={'nome_cocktail': self.nome_cocktail})
class Meta:
verbose_name = "Cocktail"
verbose_name_plural = "Cocktails"