简体   繁体   中英

Django Model Form Require Boolean Field To Be Checked True To Submit Form

I would like a boolean field to be required to true in order for the form to be submitted and to throw an error to agree to the terms. Best way to do this?

I see two solutions here:

  1. You check if your input is checked in the processing of your form inside your Django view, but this means potentially going back and forth between the server and the client side if the input is not checked.
  2. You do the checking only on the client side using Javascript. I would recommend this solution as this improves user experience (well it's more the other solution would degrades it I think).

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM