Skip to content

Instantly share code, notes, and snippets.

@ewelina29
Last active April 14, 2021 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewelina29/c025651c47948e46e630dbbf1d4e211b to your computer and use it in GitHub Desktop.
Save ewelina29/c025651c47948e46e630dbbf1d4e211b to your computer and use it in GitHub Desktop.
from django.db import models
class Ingredient(models.Model):
name = models.TextField(max_length=20)
class Sauce(models.Model):
name = models.TextField(max_length=20)
class Pizza(models.Model):
name = models.TextField(max_length=20)
  price = models.DecimalField(decimal_places=2, max_digits=4)
  ingredients = models.ManyToManyField(Ingredient)
  sauce = models.ForeignKey(Sauce, null=True, blank=True, on_delete=models.SET_NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment