File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments