mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-26 16:42:54 +03:00
Docs: Update Cookbook tutorial
This commit is contained in:
parent
24706f50d4
commit
443b5eaafc
|
@ -68,7 +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(
|
||||||
|
Category, related_name='ingredients', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -80,9 +81,21 @@ Add ingredients as INSTALLED_APPS:
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
...
|
...
|
||||||
# Install the ingredients app
|
# Install the ingredients app
|
||||||
'ingredients',
|
'cookbook.ingredients',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
Don't forget to create & run migrations:
|
Don't forget to create & run migrations:
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
Loading…
Reference in New Issue
Block a user