Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Django Design Patterns and Best Practices. - Second Edition

You're reading from  Django Design Patterns and Best Practices. - Second Edition

Product type Book
Published in May 2018
Publisher Packt
ISBN-13 9781788831345
Pages 282 pages
Edition 2nd Edition
Languages
Author (1):
Arun Ravindran Arun Ravindran
Profile icon Arun Ravindran
Toc

Table of Contents (21) Chapters close

Title Page
Copyright and Credits
PacktPub.com
Contributors
Preface
1. Django and Patterns 2. Application Design 3. Models 4. Views and URLs 5. Templates 6. Admin Interface 7. Forms 8. Working Asynchronously 9. Creating APIs 10. Dealing with Legacy Code 11. Testing and Debugging 12. Security 13. Production-Ready 1. Python 2 Versus Python 3 2. Other Books You May Enjoy Index

How forms work


Forms can be tricky to understand because interacting with them takes more than one request-response cycle. In the simplest scenario, you need to present an empty form, which the user then fills in correctly and submits. Conversely, they might enter some invalid data, in which case the form needs to be resubmitted until the entire form is valid.

From this scenario, we can see that a form can be one of several states, changing between them:

  • Empty form (unfilled form): This form is called an unbound form in Django
  • Filled form: This form is called a bound form in Django
  • Submitted form with errors: This form is called a bound form but not a valid form
  • Submitted form without errors: This form is called a bound and valid form

Note

The users will never see the form in the submitted form without errors state. They don't have to. Typically, submitting a valid form should take the users to a success page.

Forms in Django

Django's form class instances contain the state of each field and, by...

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 $15.99/month. Cancel anytime}