1
我必須單獨放置表單的字段,因爲對我來說它的風格更容易一些,我的問題是,我似乎無法讓它在驗證中顯示錯誤消息。表單驗證正確,它只是沒有顯示我得到錯誤時得到的錯誤,而只是沒有提交。我怎樣才能解決這個問題?如何用django單個字段顯示錶單驗證錯誤?
模板:
<form action="#" method="post"> {%csrf_token%} {{form.management_form}}
{%for f in form%}
{{ f.non_field_errors }}
<div class="row">
<div class="medium-3 columns ">
<label> First Name
{{ member_fname.errors }}
{{f.member_fname}}
</label>
</div>
<div class="medium-3 columns ">
<label> Last Name
{{ member_lname.errors }}
{{f.member_lname}}
</label>
</div>
<div class="medium-3 columns ">
<label> Email
{{ member_email.errors }}
{{f.member_email}}
</label>
</div>
<div class="medium-3 columns ">
<label> Phone #
{{ member_phone.errors }}
{{f.member_phone}}
</label>
</div>
</div>
<hr/>
{%endfor%}
<div class="row">
<div class="small-3 columns small-centered">
<button type="submit" class="button medium radius"> submit</button>
</div>
</div>
</div>
</form>