On Sep 22, 9:59 am, Donn <[EMAIL PROTECTED]> wrote: > Hi, > I would like to change the 'already exists' message when one adds a record > that duplicates a unique one in the table. > Nearest I can tell, the fields.error_messages do not offer a way to alter that > message. > > Here's my basic code: > > class AAForm( ModelForm ): > def __init__(self,*args,**kwargs): > super(AAForm, self).__init__(*args,**kwargs) > self.fields['fullname'].error_messages = { > 'required':'Be there no name?', > 'already_exists':'blah' #<-- this one is a dud > } > class Meta: > model = AuthorArtist > \d
No, apparently not. There's a ticket in for this (#8913) but in the meantime maybe you could define a clean() method and catch and re- raise the ValidationError there. class AAForm(ModelForm): ... blah .... def clean(self): try: self.validate_unique() except ValidationError: raise ValidationError('Hey guys, this one's already there!') return self.cleaned_data -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---