Skip to content

Commit fa178a0

Browse files
committed
errors in code
1 parent ad063aa commit fa178a0

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9 on 2016-11-04 01:06
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('recipes', '0001_initial'),
12+
]
13+
14+
operations = [
15+
migrations.RenameField(
16+
model_name='recipeingredient',
17+
old_name='recipes',
18+
new_name='recipe',
19+
),
20+
migrations.AlterField(
21+
model_name='recipeingredient',
22+
name='unit',
23+
field=models.CharField(choices=[(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20),
24+
),
25+
]

examples/cookbook/cookbook/recipes/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Recipe(models.Model):
99
__unicode__ = lambda self: self.title
1010

1111
class RecipeIngredient(models.Model):
12-
recipes = models.ForeignKey(Recipe, related_name='amounts')
12+
recipe = models.ForeignKey(Recipe, related_name='amounts')
1313
ingredient = models.ForeignKey(Ingredient, related_name='used_by')
1414
amount = models.FloatField()
1515
unit = models.CharField(max_length=20, choices=(

examples/cookbook/cookbook/recipes/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class Meta:
2020
filter_fields = {
2121
'ingredient__name': ['exact', 'icontains', 'istartswith'],
2222
'recipe': ['exact'],
23-
'recipe__name': ['icontains'],
23+
'recipe__title': ['icontains'],
2424
}
25-
filter_order_by = ['ingredient__name', 'recipe__name',]
25+
filter_order_by = ['ingredient__name', 'recipe__title',]
2626

2727
class Query(AbstractType):
2828
recipe = Node.Field(RecipeNode)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from cookbook.ingredients.models import Recipe, Ingredient
2+
from graphene import AbstractType, Node
3+
from graphene_django.filter import DjangoFilterConnectionField
4+
from graphene_django.types import DjangoObjectType
5+
6+
class RecipeNode(DjangoObjectType):
7+
8+
class Meta:
9+
model = Recipe
10+
interfaces = (Node, )
11+
filter_fields = ['name', 'ingredients']
12+
filter_order_by = ['name']
13+
14+
class RecipeIngredientNode(DjangoObjectType):
15+
16+
class Meta:
17+
model = RecipeIngredient
18+
# Allow for some more advanced filtering here
19+
interfaces = (Node, )
20+
filter_fields = {
21+
'name': ['exact', 'icontains', 'istartswith'],
22+
'notes': ['exact', 'icontains'],
23+
'recipe': ['exact'],
24+
'recipe__name': ['icontains'],
25+
}
26+
filter_order_by = ['name', 'recipe__name',]
27+
28+
class Query(AbstractType):
29+
recipe = Node.Field(RecipeNode)
30+
all_categories = DjangoFilterConnectionField(RecipeNode)
31+
32+
recipeingredient = Node.Field(IngredientNode)
33+
all_recipeingredients = DjangoFilterConnectionField(RecipeIngredientNode)

0 commit comments

Comments
 (0)