如何选中复选框是用django模板中的if语句选中的



我正在制作一个注册表格,在用户选中复选框接受条款和条件之前,必须禁用注册(提交(按钮。当用户选中该框时,该按钮将被启用。

这是复选框

<label for="agree"><input type="checkbox" id="agree" name="agree" value="checked"><span style="color: springgreen;">I AGREE, to the terms and conditions.</span></label><br>

这是处于条件下的按钮

<input type="submit" value="REGISTER" >

Sir如果你想在Django中注册用户,那么就为它制作自定义的用户表单。

但另一个临时解决方案是只添加

<input type="checkbox" id="agree" name="agree" value="checked" required>

但在末尾添加所需内容,但在表单部分中插入此行

但有一个问题,数据库中没有使用过的条目但是的,用户在没有检查之前无法登录

如果你想以专业的方式来做,那么就让自定义用户与布尔菲尔德存在参考链接https://www.fomfus.com/articles/how-to-use-email-as-username-for-django-authentication-removing-the-username/

这只是一个示例链接s

最新更新