@@ -68,8 +68,8 @@ Let's get started with these models:
68
68
class Ingredient (models .Model ):
69
69
name = models.CharField(max_length = 100 )
70
70
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 )
73
73
74
74
def __str__ (self ):
75
75
return self .name
@@ -84,6 +84,7 @@ Add ingredients as INSTALLED_APPS:
84
84
' cookbook.ingredients' ,
85
85
]
86
86
87
+
87
88
Don't forget to create & run migrations:
88
89
89
90
.. code :: bash
@@ -112,6 +113,18 @@ Alternatively you can use the Django admin interface to create some data
112
113
yourself. You'll need to run the development server (see below), and
113
114
create a login for yourself too (``./manage.py createsuperuser ``).
114
115
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
+
115
128
Hello GraphQL - Schema and Object Types
116
129
---------------------------------------
117
130
0 commit comments