Skip to content
Snippets Groups Projects
Commit 188b859d authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

Création des migrations

parent b4f939b5
No related branches found
No related tags found
No related merge requests found
from django.db import models
# Create your models here.
# Ingredients
class Ingredient(models.Model):
id = models.AutoField(primary_key=True)
nom = models.CharField(max_length=50, verbose_name="Nom de l'ingrédient")
def __str__(self) -> str:
return self.nom
# Pizza
class Pizza(models.Model):
id = models.AutoField(primary_key=True)
nom = models.CharField(max_length=50, verbose_name="Nom de la pizza")
prix = models.FloatField(verbose_name="Prix de la pizza")
def __str__(self) -> str:
return self.nom
# Composition
class Composition(models.Model):
id = models.AutoField(primary_key=True)
pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE)
ingredient = models.ForeignKey(Ingredient, on_delete=models.CASCADE)
quantite = models.FloatField(verbose_name="Quantité de l'ingrédient")
def __str__(self) -> str:
return f"{self.pizza} - {self.ingredient} - {self.quantite}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment