diff --git a/examples/cookbook-plain/README.md b/examples/cookbook-plain/README.md index 4075082..0ec906b 100644 --- a/examples/cookbook-plain/README.md +++ b/examples/cookbook-plain/README.md @@ -3,7 +3,7 @@ Cookbook Example Django Project This example project demos integration between Graphene and Django. The project contains two apps, one named `ingredients` and another -named `recepies`. +named `recipes`. Getting started --------------- diff --git a/examples/cookbook-plain/cookbook/ingredients/tests.py b/examples/cookbook-plain/cookbook/ingredients/tests.py new file mode 100644 index 0000000..4929020 --- /dev/null +++ b/examples/cookbook-plain/cookbook/ingredients/tests.py @@ -0,0 +1,2 @@ + +# Create your tests here. diff --git a/examples/cookbook-plain/cookbook/ingredients/views.py b/examples/cookbook-plain/cookbook/ingredients/views.py new file mode 100644 index 0000000..b8e4ee0 --- /dev/null +++ b/examples/cookbook-plain/cookbook/ingredients/views.py @@ -0,0 +1,2 @@ + +# Create your views here. diff --git a/examples/cookbook-plain/cookbook/recipes/models.py b/examples/cookbook-plain/cookbook/recipes/models.py index e688044..ca12fac 100644 --- a/examples/cookbook-plain/cookbook/recipes/models.py +++ b/examples/cookbook-plain/cookbook/recipes/models.py @@ -6,6 +6,7 @@ from cookbook.ingredients.models import Ingredient class Recipe(models.Model): title = models.CharField(max_length=100) instructions = models.TextField() + __unicode__ = lambda self: self.title class RecipeIngredient(models.Model): diff --git a/examples/cookbook-plain/cookbook/recipes/tests.py b/examples/cookbook-plain/cookbook/recipes/tests.py new file mode 100644 index 0000000..4929020 --- /dev/null +++ b/examples/cookbook-plain/cookbook/recipes/tests.py @@ -0,0 +1,2 @@ + +# Create your tests here. diff --git a/examples/cookbook-plain/cookbook/recipes/views.py b/examples/cookbook-plain/cookbook/recipes/views.py new file mode 100644 index 0000000..b8e4ee0 --- /dev/null +++ b/examples/cookbook-plain/cookbook/recipes/views.py @@ -0,0 +1,2 @@ + +# Create your views here. diff --git a/examples/cookbook/cookbook/ingredients/admin.py b/examples/cookbook/cookbook/ingredients/admin.py index 2b16cdc..b57cbc3 100644 --- a/examples/cookbook/cookbook/ingredients/admin.py +++ b/examples/cookbook/cookbook/ingredients/admin.py @@ -2,9 +2,11 @@ from django.contrib import admin from cookbook.ingredients.models import Category, Ingredient + @admin.register(Ingredient) class IngredientAdmin(admin.ModelAdmin): - list_display = ("id","name","category") - list_editable = ("name","category") - + list_display = ('id', 'name', 'category') + list_editable = ('name', 'category') + + admin.site.register(Category) diff --git a/examples/cookbook/cookbook/ingredients/models.py b/examples/cookbook/cookbook/ingredients/models.py index a072bcf..2f0eba3 100644 --- a/examples/cookbook/cookbook/ingredients/models.py +++ b/examples/cookbook/cookbook/ingredients/models.py @@ -10,7 +10,7 @@ class Category(models.Model): class Ingredient(models.Model): 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') def __str__(self): diff --git a/examples/cookbook/cookbook/recipes/admin.py b/examples/cookbook/cookbook/recipes/admin.py index 57e0418..10d568f 100644 --- a/examples/cookbook/cookbook/recipes/admin.py +++ b/examples/cookbook/cookbook/recipes/admin.py @@ -2,9 +2,11 @@ from django.contrib import admin from cookbook.recipes.models import Recipe, RecipeIngredient + class RecipeIngredientInline(admin.TabularInline): - model = RecipeIngredient + model = RecipeIngredient + @admin.register(Recipe) class RecipeAdmin(admin.ModelAdmin): - inlines = [RecipeIngredientInline] + inlines = [RecipeIngredientInline] diff --git a/examples/cookbook/cookbook/recipes/models.py b/examples/cookbook/cookbook/recipes/models.py index f666fe8..ca12fac 100644 --- a/examples/cookbook/cookbook/recipes/models.py +++ b/examples/cookbook/cookbook/recipes/models.py @@ -8,6 +8,7 @@ class Recipe(models.Model): instructions = models.TextField() __unicode__ = lambda self: self.title + class RecipeIngredient(models.Model): recipe = models.ForeignKey(Recipe, related_name='amounts') ingredient = models.ForeignKey(Ingredient, related_name='used_by') diff --git a/examples/cookbook/cookbook/schema.py b/examples/cookbook/cookbook/schema.py index 910e259..f8606a7 100644 --- a/examples/cookbook/cookbook/schema.py +++ b/examples/cookbook/cookbook/schema.py @@ -5,7 +5,9 @@ import graphene from graphene_django.debug import DjangoDebug -class Query(cookbook.recipes.schema.Query, cookbook.ingredients.schema.Query, graphene.ObjectType): +class Query(cookbook.ingredients.schema.Query, + cookbook.recipes.schema.Query, + graphene.ObjectType): debug = graphene.Field(DjangoDebug, name='__debug') diff --git a/examples/cookbook/cookbook/settings.py b/examples/cookbook/cookbook/settings.py index 1916201..948292d 100644 --- a/examples/cookbook/cookbook/settings.py +++ b/examples/cookbook/cookbook/settings.py @@ -1,3 +1,4 @@ +# flake8: noqa """ Django settings for cookbook project. diff --git a/examples/cookbook/cookbook/urls.py b/examples/cookbook/cookbook/urls.py index 9410ca5..9f8755b 100644 --- a/examples/cookbook/cookbook/urls.py +++ b/examples/cookbook/cookbook/urls.py @@ -3,6 +3,7 @@ from django.contrib import admin from graphene_django.views import GraphQLView + urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^graphql', GraphQLView.as_view(graphiql=True)), diff --git a/examples/cookbook/setup.cfg b/examples/cookbook/setup.cfg new file mode 100644 index 0000000..8c6a6e8 --- /dev/null +++ b/examples/cookbook/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +exclude=migrations,.git,__pycache__