Opened 4 years ago

Closed 17 months ago

#16192 closed New feature (fixed)

Make unique_together error messages in ModelForms customizable

Reported by: leahculver Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: orokusaki, tinodb, mwarkentin, schickm, andrewgodwin, loic@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This is related to ticket #8913 and Google groups discussion: http://groups.google.com/group/django-developers/browse_thread/thread/6306fea94a537c3b

Allow developers to specify a unique_together custom error_message on their model. This is more difficult than #8913 since the syntax is less obvious. Should there be something in the Meta?

Change History (12)

comment:1 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by aaugustin

  • Component changed from Forms to Database layer (models, ORM)

comment:3 Changed 3 years ago by Marboni

Are you guys plan to fix it in 1.4?

comment:4 Changed 3 years ago by aaugustin

This ticket hasn't gotten much attention. Apparently, no one cares enough to write a patch. Until someone does, the feature won't be implemented.

comment:5 Changed 3 years ago by anonymous

I think it should get the attention it deserves. Providing the checking of the fields without allowing to use a proper error message is like buying a car which an alarm but without a door.

comment:6 Changed 17 months ago by glynjackson

More attention please! Are there any plans for this yet? I'm not confident enough yet to submit a patch but would like to work on this with someone.

comment:7 Changed 17 months ago by glynjackson

  • Version changed from 1.3 to 1.6

comment:8 Changed 17 months ago by loic84

  • Cc loic@… added
  • Has patch set
  • Version changed from 1.6 to master

@glynjackson, I've had a go at this, could you please check if it solves your issue?

https://github.com/django/django/pull/2235

comment:9 Changed 17 months ago by timo

  • Needs documentation set

Looks reasonable to me, but needs documentation.

comment:10 Changed 17 months ago by loic84

@timo what kind of documentation do you have in mind? Just an entry in the release notes?

comment:11 Changed 17 months ago by loic84

  • Needs documentation unset

Added documentation to the PR.

comment:12 Changed 17 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 8847a0c601e4261823b1726b2db73eec2ac17940:

Fixed #16192 -- Made unique error messages in ModelForm customizable.

Overriding the error messages now works for both unique fields, unique_together
and unique_for_date.

This patch changed the overriding logic to allow customizing NON_FIELD_ERRORS
since previously only fields' errors were customizable.

Refs #20199.

Thanks leahculver for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top