Skip to content

Instantly share code, notes, and snippets.

@chris001177
Created June 27, 2019 15:30
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 chris001177/3e47bccd110e664e1f59eeed91a014de to your computer and use it in GitHub Desktop.
Save chris001177/3e47bccd110e664e1f59eeed91a014de to your computer and use it in GitHub Desktop.
# cookbook/ingredients/models.py
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
class Ingredient(models.Model):
name = models.CharField(max_length=100)
notes = models.TextField()
category = models.ForeignKey(
Category, related_name='ingredients', on_delete=models.CASCADE)
def __str__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment