1đź‘Ť
âś…
Errors are shown for the “data” parameter ( or instance if it’s a modelform ), not “initial”. You need to pass the original values as the data parameter if you want to display errors.
And then just use the usual validation methods ( raising ValidationError in clean_* methods , field specific validation, etc. ). I wouldn’t mess up with the error dictionary, it’s an internal API.
👤vincent
0đź‘Ť
If you want to do custom form validation, you can implement the clean_<fieldname>()
or clean()
method on your form, and raise a ValidationError
for each error. See the official documentation for details
👤sk1p
- [Answer]-Ways to handle thumbnails with Django?
- [Answer]-Python gearman Received non-binary argument
- [Answer]-How to get number of items grouped by a property of an intermediate model
- [Answer]-Django change foreignkey Field
- [Answer]-How can I filter a query by a GenericForeignKey-Field using another query as possible values?
Source:stackexchange.com