mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 17:47:12 +03:00
Make cookbook example working on django 2 (#680)
This commit is contained in:
parent
612ba5a4ea
commit
91c1278d1a
|
@ -11,7 +11,9 @@ class Category(models.Model):
|
||||||
class Ingredient(models.Model):
|
class Ingredient(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
notes = models.TextField(null=True, blank=True)
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -10,8 +10,10 @@ class Recipe(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class RecipeIngredient(models.Model):
|
class RecipeIngredient(models.Model):
|
||||||
recipe = models.ForeignKey(Recipe, related_name="amounts")
|
recipe = models.ForeignKey(Recipe, related_name="amounts", on_delete=models.CASCADE)
|
||||||
ingredient = models.ForeignKey(Ingredient, related_name="used_by")
|
ingredient = models.ForeignKey(
|
||||||
|
Ingredient, related_name="used_by", on_delete=models.CASCADE
|
||||||
|
)
|
||||||
amount = models.FloatField()
|
amount = models.FloatField()
|
||||||
unit = models.CharField(
|
unit = models.CharField(
|
||||||
max_length=20,
|
max_length=20,
|
||||||
|
|
|
@ -43,13 +43,12 @@ INSTALLED_APPS = [
|
||||||
"cookbook.recipes.apps.RecipesConfig",
|
"cookbook.recipes.apps.RecipesConfig",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
"django.middleware.common.CommonMiddleware",
|
"django.middleware.common.CommonMiddleware",
|
||||||
"django.middleware.csrf.CsrfViewMiddleware",
|
"django.middleware.csrf.CsrfViewMiddleware",
|
||||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
|
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
graphene
|
graphene
|
||||||
graphene-django
|
graphene-django
|
||||||
graphql-core>=2.1rc1
|
graphql-core>=2.1rc1
|
||||||
django==1.11.21
|
django==2.2.2
|
||||||
django-filter>=2
|
django-filter>=2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user