[Django]-Asterisk in django forms validation messages

3👍

So, i just had to iterate over errors and print them without as_text()

14👍

One more way:

{{ form.username.errors.as_text|cut:"* " }}
👤Taylor

3👍

The asterisks are added when print the field errors as_text. See django/forms/util.py ErrorList for more detail. It is easier to customize the errors if you print them as_ul instead. The ul will be given a class “errorlist”. The Django book has a section on customizing the form errors. Chapter 7 under “Customizing Form Design”: http://www.djangobook.com/en/2.0/chapter07/

Leave a comment