Django: Display a custom error message for admin validation error

前端 未结 1 566
醉梦人生
醉梦人生 2021-02-19 21:57

I\'m using Django 1.2.4. I have a model that has a field that needs to be validated. When validation fails, I\'d like to display a custom error message to the user. Model editin

相关标签:
1条回答
  • 2021-02-19 22:28

    Without looking, it sounds like the admin is looking for an iterable as the value for field_name. Try:

    raise ValidationError({'field_name': ["error message",]})
    

    I think the admin expects any number of validation messages to be associated with each field on a form.

    0 讨论(0)
提交回复
热议问题