Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Becoming an Enterprise Django Developer

You're reading from   Becoming an Enterprise Django Developer Discover best practices, tooling, and solutions for writing and organizing Django applications in production

Arrow left icon
Product type Paperback
Published in Jun 2022
Publisher Packt
ISBN-13 9781801073639
Length 526 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Mike Dinder Mike Dinder
Author Profile Icon Mike Dinder
Mike Dinder
Michael Dinder Michael Dinder
Author Profile Icon Michael Dinder
Michael Dinder
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Part 1 – Starting a Project
2. Chapter 1: Undertaking a Colossal Project FREE CHAPTER 3. Chapter 2: Project Configuration 4. Chapter 3: Models, Relations, and Inheritance 5. Part 2 – Django Components
6. Chapter 4: URLs, Views, and Templates 7. Chapter 5: Django Forms 8. Chapter 6: Exploring the Django Admin Site 9. Chapter 7: Working with Messages, Email Notifications, and PDF Reports 10. Part 3 – Advanced Django Components
11. Chapter 8: Working with the Django REST Framework 12. Chapter 9: Django Testing 13. Chapter 10: Database Management 14. Other Books You May Enjoy

Rendering forms in templates

Django offers five main ways to easily and quickly render a form object onto a page. The first three are to render a form using a paragraph, table, or list structure. The other two include the traditional way of rendering a form, which is based on the template in the django.forms.templates.django.forms library called default.html, and then a way to render your own template. New to Django 4.0 is the template_name option on all form classes. This option allows you to point to a template file where you can structure your own HTML formatting.

Follow these steps to render your form objects:

  1. Copy the base_template_1.html file that was created in Chapter 4, URLs, Views, and Templates, into your /becoming_a_django_entdev/chapter_5/templates/chapter_5/base/ folder. Copy all related partial template files that are added as {% include %} statements into that file as well.
  2. That base_template_1.html file will be repurposed as the base template for this...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image