0

I have the following code, It works properly but the issue is that i want to be able to change the message that shows This Field is Required, or when it says this is invalid I know there is a way to add this but the many that i've tried before did not work. this way works but i'm not able to modify the messages.

from django import forms
from models import user


class loginForm(forms.ModelForm):

    class Meta:
        model = user
        fields = ('username', 'password',)
Eddwin Paz
  • 2,842
  • 4
  • 28
  • 48
  • possible duplicate of [custom error messages with Model Form](http://stackoverflow.com/questions/3436712/custom-error-messages-with-model-form) – Two-Bit Alchemist Mar 12 '14 at 21:18
  • the answer is from django import forms from user.models import user class loginForm(forms.ModelForm): class Meta: model = user fields = ('username',) error_messages = { 'username': { 'required': ('Please enter username'), }, } – Eddwin Paz Mar 13 '14 at 02:30
  • You can post an answer to your own question and accept it. – Two-Bit Alchemist Mar 13 '14 at 05:15

1 Answers1

0

This is the answer that worked for me in this case. Hope helps anyone who has this issue also.

from django import forms 
from user.models import user 

class loginForm(forms.ModelForm): 

    class Meta: 
          model = user 
          fields = ('username') 

          error_messages = { 
              'username': { 
                  'required': ('Please enter username'), 
              }, 
          }
Eddwin Paz
  • 2,842
  • 4
  • 28
  • 48