Make cookbook example working on django 2 (#680)

This commit is contained in:
Semyon Pupkov 2019-06-19 15:59:19 +05:00 committed by Paul Hallett
parent 612ba5a4ea
commit 91c1278d1a
4 changed files with 9 additions and 6 deletions

View File

@ -11,7 +11,9 @@ class Category(models.Model):
class Ingredient(models.Model):
name = models.CharField(max_length=100)
notes = models.TextField(null=True, blank=True)
category = models.ForeignKey(Category, related_name="ingredients")
category = models.ForeignKey(
Category, related_name="ingredients", on_delete=models.CASCADE
)
def __str__(self):
return self.name

View File

@ -10,8 +10,10 @@ class Recipe(models.Model):
class RecipeIngredient(models.Model):
recipe = models.ForeignKey(Recipe, related_name="amounts")
ingredient = models.ForeignKey(Ingredient, related_name="used_by")
recipe = models.ForeignKey(Recipe, related_name="amounts", on_delete=models.CASCADE)
ingredient = models.ForeignKey(
Ingredient, related_name="used_by", on_delete=models.CASCADE
)
amount = models.FloatField()
unit = models.CharField(
max_length=20,

View File

@ -43,13 +43,12 @@ INSTALLED_APPS = [
"cookbook.recipes.apps.RecipesConfig",
]
MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

View File

@ -1,5 +1,5 @@
graphene
graphene-django
graphql-core>=2.1rc1
django==1.11.21
django==2.2.2
django-filter>=2