我想让django表单默认的错误信息显示为红色和加粗。例如,将"This field is required"显示为红色和加粗。我看到了error_css_class = 'error',但它没有起作用。
https://docs.djangoproject.com/en/1.5//ref/forms/api/#django.forms.Form.error_css_class
谢谢!
这是我的models.py文件。
这是我的模板:
class RegiForm(forms.Form):
error_css_class = 'error'
DateInput = partial(forms.DateInput, {'class': 'datepicker'})
email = forms.EmailField(max_length=75)
first_name = forms.CharField(max_length=25)
last_name = forms.CharField(max_length=25)
address = forms.CharField(max_length=200)
这是我的模板:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>RegistrationForm</title>
</head>
<body>
<h1>Registration Form</h1>
<form action="/login/regi/" method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
</body>
</html>