[Answered ]-Showing custom error messages in django model form with bootstrap

2👍

Change form.name.error_messages to form.name.errors in your template.

It seems you render fields/errors one by one manually, explained here:

You may want to consider a more automatic approach using a {% for %} template tag.

EDIT: To change the default error message, you need to update your error_messages in the form Meta and overwrite the key used by django, in this case it is key invalid, based on IntegerField source:

class Meta:
    model = Test
    fields = '__all__'
    error_messages = {
        'some_integer_field': {
            'invalid': 'some custom invalid message',
        },
    }
👤fips

Leave a comment