Django - The Easy Way (2nd Edition): A step-by-step guide on building Django websites by Samuli Natri

Django - The Easy Way (2nd Edition): A step-by-step guide on building Django websites by Samuli Natri

Author:Samuli Natri [Natri, Samuli]
Language: eng
Format: azw3
Publisher: leanpub.com
Published: 2018-12-14T16:00:00+00:00


Edit the flowers and select a category for each item. You can create the referenced Category object while you are editing the Flower objects:

17.3 Updating the homepage template

Edit the myapp index.html template file and print out the category:

myapp/templates/myapp/index.html <p class="card-text">{{ flower.description | truncatechars:\ 100 }}</p> <a href="#" class="card-link">{{ flower.category }}</a> <!-\ - here -->

17.4 Details

17.4.1 Examining many-to-one relationships

ForeignKey is a many-to-one relationship:

myapp/models.py category = models.ForeignKey(Category, on_delete=models.PRO\ TECT, null=True)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.