Skip to content

Commit 443b5ea

Browse files
authored
Docs: Update Cookbook tutorial
1 parent 24706f5 commit 443b5ea

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/tutorial-plain.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +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')
71+
category = models.ForeignKey(
72+
Category, related_name='ingredients', on_delete=models.CASCADE)
7273
7374
def __str__(self):
7475
return self.name
@@ -80,9 +81,21 @@ Add ingredients as INSTALLED_APPS:
8081
INSTALLED_APPS = [
8182
...
8283
# Install the ingredients app
83-
'ingredients',
84+
'cookbook.ingredients',
8485
]
8586
87+
Register models with admin panel:
88+
89+
.. code:: python
90+
91+
# cookbook/ingredients/admin.py
92+
from django.contrib import admin
93+
from cookbook.ingredients.models import Category, Ingredient
94+
95+
admin.site.register(Category)
96+
admin.site.register(Ingredient)
97+
98+
8699
Don't forget to create & run migrations:
87100

88101
.. code:: bash

0 commit comments

Comments
 (0)