Code

Ticket #2194: django-unique-together-error.diff

File django-unique-together-error.diff, 890 bytes (added by dackze+django@…, 8 years ago)

Makes validator use only verbose names in this error message

Line 
1Index: django/db/models/manipulators.py
2===================================================================
3--- django/db/models/manipulators.py    (revision 3740)
4+++ django/db/models/manipulators.py    (working copy)
5@@ -300,7 +300,9 @@
6         pass
7     else:
8         raise validators.ValidationError, _("%(object)s with this %(type)s already exists for the given %(field)s.") % \
9-            {'object': capfirst(opts.verbose_name), 'type': field_list[0].verbose_name, 'field': get_text_list(field_name_list[1:], 'and')}
10+            {'object': capfirst(opts.verbose_name),
11+             'type': field_list[0].verbose_name,
12+             'field': get_text_list([f.verbose_name for f in field_list[1:]], 'and')}
13 
14 def manipulator_validator_unique_for_date(from_field, date_field, opts, lookup_type, self, field_data, all_data):
15     from django.db.models.fields.related import ManyToOneRel