@@ -68,8 +68,8 @@ Let's get started with these models:
6868 class Ingredient (models .Model ):
6969 name = models.CharField(max_length = 100 )
7070 notes = models.TextField()
71- category = models.ForeignKey(Category, related_name = ' ingredients ' ,
72- on_delete = models.CASCADE )
71+ category = models.ForeignKey(
72+ Category, related_name = ' ingredients ' , on_delete = models.CASCADE )
7373
7474 def __str__ (self ):
7575 return self .name
@@ -84,6 +84,7 @@ Add ingredients as INSTALLED_APPS:
8484 ' cookbook.ingredients' ,
8585 ]
8686
87+
8788 Don't forget to create & run migrations:
8889
8990.. code :: bash
@@ -112,6 +113,18 @@ Alternatively you can use the Django admin interface to create some data
112113yourself. You'll need to run the development server (see below), and
113114create a login for yourself too (``./manage.py createsuperuser ``).
114115
116+ Register models with admin panel:
117+
118+ .. code :: python
119+
120+ # cookbook/ingredients/admin.py
121+ from django.contrib import admin
122+ from cookbook.ingredients.models import Category, Ingredient
123+
124+ admin.site.register(Category)
125+ admin.site.register(Ingredient)
126+
127+
115128 Hello GraphQL - Schema and Object Types
116129---------------------------------------
117130
0 commit comments