Adding name to fieldsets to improve their validation error text

已查看 62 次
跳至第一个未读帖子

Benjamin W Stookey

未读,
2015年12月17日 17:46:042015/12/17
收件人 Django developers (Contributions to Django itself)
Right now, if min or max validation doesn't pass on a fieldset, we provide something like the following error:

Please submit 1 or more forms.

I'd like to propose that we provide a way to generate a slightly more specific error. For example:

Please submit 1 or more authors.

I'm eager to write the code to do this. There are a number of ways to implement it so I figured it would need discussion first and a ticket before I could issue a pull request. If people think this is a good idea, I'll document a few potential approaches for discussion.

A few options that come to mind before diving in.
  • Adding a `verbose_name_plural` property to the formset
  • Pulling the `verbose_name_plural` from the form class (if forms are model forms)
Thanks,
-Ben

Tim Graham

未读,
2015年12月30日 18:17:472015/12/30
收件人 Django developers (Contributions to Django itself)
Hi Ben,

From a quick look, I'd suggest trying an approach similar to how form fields work, with a `default_error_messages` class attribute which can be override by an `error_messages` parameter provided to __init__().

Tim
回复全部
回复作者
转发
0 个新帖子