问题描述:

Doing some maintenance on a django 1.3 app.

There is a class Application with (amonst others) an IntegerField:

area = models.IntegerField()

They are wanting a different error message for invalid entries.

After sifting through all the docs and trying many approaches I haven't managed to resolve this.

For example I tried:

area = models.IntegerField(error_messages={'invalid': 'Custom message'})

Also:

class ApplicationForm(ModelForm):

area = forms.IntegerField({'invalid': 'Custom message'})

class Meta:

model = Application

fields = ('...) #all the other fields go here

Also other approaches didn't work. I always get the standard "Enter a whole number." error message.

相关阅读:
Top