From 443b5eaafc22919d828b30a1d86cf8c117c0b8e6 Mon Sep 17 00:00:00 2001 From: Stefan Stammberger Date: Sat, 2 Dec 2017 19:35:17 +0100 Subject: [PATCH] Docs: Update Cookbook tutorial --- docs/tutorial-plain.rst | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/tutorial-plain.rst b/docs/tutorial-plain.rst index eca7904..966d973 100644 --- a/docs/tutorial-plain.rst +++ b/docs/tutorial-plain.rst @@ -68,7 +68,8 @@ Let's get started with these models: class Ingredient(models.Model): name = models.CharField(max_length=100) notes = models.TextField() - category = models.ForeignKey(Category, related_name='ingredients') + category = models.ForeignKey( + Category, related_name='ingredients', on_delete=models.CASCADE) def __str__(self): return self.name @@ -80,9 +81,21 @@ Add ingredients as INSTALLED_APPS: INSTALLED_APPS = [ ... # 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: .. code:: bash