mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-01-31 11:48:38 +03:00
Merge pull request #334 from fusion44/master
Docs: Update Cookbook tutorial
This commit is contained in:
commit
9812c58a86
|
@ -68,8 +68,8 @@ Let's get started with these models:
|
||||||
class Ingredient(models.Model):
|
class Ingredient(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
notes = models.TextField()
|
notes = models.TextField()
|
||||||
category = models.ForeignKey(Category, related_name='ingredients',
|
category = models.ForeignKey(
|
||||||
on_delete=models.CASCADE)
|
Category, related_name='ingredients', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -84,6 +84,7 @@ Add ingredients as INSTALLED_APPS:
|
||||||
'cookbook.ingredients',
|
'cookbook.ingredients',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
Don't forget to create & run migrations:
|
Don't forget to create & run migrations:
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
@ -112,6 +113,18 @@ Alternatively you can use the Django admin interface to create some data
|
||||||
yourself. You'll need to run the development server (see below), and
|
yourself. You'll need to run the development server (see below), and
|
||||||
create a login for yourself too (``./manage.py createsuperuser``).
|
create a login for yourself too (``./manage.py createsuperuser``).
|
||||||
|
|
||||||
|
Register models with admin panel:
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
# cookbook/ingredients/admin.py
|
||||||
|
from django.contrib import admin
|
||||||
|
from cookbook.ingredients.models import Category, Ingredient
|
||||||
|
|
||||||
|
admin.site.register(Category)
|
||||||
|
admin.site.register(Ingredient)
|
||||||
|
|
||||||
|
|
||||||
Hello GraphQL - Schema and Object Types
|
Hello GraphQL - Schema and Object Types
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user