Opened 5 months ago
Closed 4 months ago
#35532 closed New feature (wontfix)
Allow customizing errors processing in BaseModelFormSet.validate_unique()
Reported by: | Christophe Henry | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Christophe Henry | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
BaseModelFormSet.validate_unique()
βdoesn't offer a way to customize errors for instance to provide a more specific message or add the error message to a specific field.
I propose to fix this problem by adding two process_unique_error
and process_date_error
that get the form, fields and values as parameters.
Please check the enclosed patch for proposed solution.
Attachments (1)
Change History (4)
by , 5 months ago
Attachment: | form.patch added |
---|
follow-up: 2 comment:1 by , 5 months ago
Resolution: | β wontfix |
---|---|
Status: | new β closed |
follow-up: 3 comment:2 by , 4 months ago
Resolution: | wontfix |
---|---|
Status: | closed β new |
Replying to Sarah Boyce:
Hi Sarah,
βSo I did what you advised but that doesn't seem to attract much attention. In the meantime, I really need this feature for a project. What should I do?
comment:3 by , 4 months ago
Resolution: | β wontfix |
---|---|
Status: | new β closed |
Replying to Christophe Henry:
βSo I did what you advised but that doesn't seem to attract much attention.
Thank you for doing so, lack of feedback can mean a few things (perhaps there is limited interest of the feature, perhaps this needs to be promoted more as it has gotten "lost", perhaps this needs more time).
In the meantime, I really need this feature for a project. What should I do?
Your proposed patch suggestion looks very similar to overwriting the existing get_unique_error_message
and get_date_error_message
methods, the added value is in customising whether the error is within NON_FIELD_ERRORS
or on a specific field from what I can see.
When I started to look into this, I noticed that βBaseModelForm.validate_unique() has a _update_errors
processing step which doesn't appear to be in BaseModelFormSet.validate_unique()
. This makes me think, how would we do this in a normal model form? Can we not do this the same way in a model formset? Is that a bug?
I don't have time to play around with this, but I think if you investigate or start asking questions from the angle of "I need to achieve this, how can I do this? How would I do this for a model form?" on one of our βuser support channels, you will probably end up with (A) the work around that you need for your project and (B) a conclusion as to whether a change in Django needs to happen.
I hope that helps. As we still don't have the community consensus that we need to make this change yet, I am closing as wontfix
Hi Christopheπ thank you for raising this, I can see why this would make error customisation easier.
For a feature request to be accepted, we want to see some discussion on the βforum first to confirm/validate the feature with the community and get some feedback (so next steps here would be to take this to the forum).
I'll close the ticket for now, but if there is a community agreement for this, you are welcome to come back linking the forum topic, so we can then re-open it.
For more details, please see βthe documented guidelines for requesting features π