You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for details on the format for `filter_fields`. While optional, this tutorial makes use of this functionality so you will need to install `django-filter` for this tutorial to work:
134
+
135
+
````bash
136
+
pip install django-filter
137
+
```
134
138
135
139
Note that the above `Query` class is marked as 'abstract'. This is because we
136
140
will now create a project-level query which will combine all our app-level
@@ -156,13 +160,15 @@ schema.query = Query
156
160
You can think of this as being something like your top-level `urls.py`
157
161
file (although it currently lacks any namespacing).
158
162
159
-
## Adding GraphiQL
163
+
## Update `INSTALLED_APPS`
160
164
161
-
GraphiQL is a web-based integrated development environment to assist in the
162
-
writing and executing of GraphQL queries. It will provide us with a simple
163
-
and easy way of testing our cookbook project.
165
+
Next, install your app and GraphiQL in your Django project. GraphiQL is
166
+
a web-based integrated development environment to assist in the writing and
167
+
executing of GraphQL queries. It will provide us with a simple and easy way
168
+
of testing our cookbook project.
164
169
165
-
Add `django_graphiql` to `INSTALLED_APPS` in `cookbook/settings.py`:
170
+
Add `ingredients`, `graphene.contrib.django` and `django_graphiql` to
171
+
`INSTALLED_APPS`in`cookbook/settings.py`:
166
172
167
173
```python
168
174
INSTALLED_APPS = [
@@ -171,9 +177,13 @@ INSTALLED_APPS = [
171
177
172
178
# This will also make the `graphql_schema` management command available
173
179
'graphene.contrib.django',
180
+
181
+
# Install the ingredients app
182
+
'ingredients',
174
183
]
175
184
```
176
185
186
+
177
187
## Creating GraphQL and GraphiQL views
178
188
179
189
Unlike a RESTful API, there is only a single URL from which GraphQL is accessed.
@@ -198,10 +208,19 @@ urlpatterns = [
198
208
]
199
209
```
200
210
211
+
## Apply model changes to database
212
+
213
+
Tell Django that we've added models and update the database schema to reflect these additions.
214
+
215
+
```bash
216
+
python manage.py makemigrations
217
+
python manage.py migrate
218
+
```
219
+
201
220
## Load some test data
202
221
203
222
Now is a good time to load up some test data. The easiest option will be to
204
-
[download the ingredients.json](https://raw.githubusercontent.com/graphql-python/graphene/feature/django/examples/cookbook/cookbook/ingredients/fixtures/ingredients.json)
223
+
[download the ingredients.json](https://raw.githubusercontent.com/graphql-python/graphene/master/examples/cookbook_django/cookbook/ingredients/fixtures/ingredients.json)
205
224
fixture and place it in
206
225
`cookbook/ingredients/fixtures/ingredients.json`. You can then run the following:
0 commit comments