Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to put some custom messages to your erros you may want to modify the clean method of your formfields.</p> <p>For example:</p> <pre><code>class Form(forms.ModelForm): class Meta: model = User #Assuming User is the name of your model fields = ['username','first_name'] def clean_first_name(self): if condition: # A condition that must raise an error raise forms.ValidationError(u'Your Custom Validation Error goes here.') return self.cleaned_data['first_name'] </code></pre> <p>But if you just want to change the name that appears in a default error message you can put a verbose name in your fields, just like:</p> <pre><code>username = models.CharField(max_length=10, verbose_name="Username") first_name = models.CharField(max_length=20, verbose_name="First Name") </code></pre> <p>or implicit:</p> <pre><code>username = models.CharField("Username", max_length=10) first_name = models.CharField("First Name",max_length=20) </code></pre> <p>To see more about django form and field validation: <a href="https://docs.djangoproject.com/en/1.5/ref/forms/validation/#form-and-field-validation" rel="nofollow noreferrer">https://docs.djangoproject.com/en/1.5/ref/forms/validation/#form-and-field-validation</a></p> <p>About Override default Form error messages: <a href="https://stackoverflow.com/questions/1481771/django-override-default-form-error-messages">Django override default form error messages</a></p> <p>and </p> <p><a href="http://davedash.com/2008/11/28/custom-error-messages-for-django-forms/" rel="nofollow noreferrer">http://davedash.com/2008/11/28/custom-error-messages-for-django-forms/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload