Handles multiple collisions with the same key.

This commit is contained in:
Pablo Chinea 2017-01-05 09:49:26 +00:00
parent 2c26774c62
commit 89d0f0ca92
2 changed files with 2 additions and 1 deletions

View File

@ -34,7 +34,7 @@ def get_choices(choices):
yield choice
else:
name = convert_choice_name(value)
if name in converted_names:
while name in converted_names:
name += '_' + str(len(converted_names))
converted_names.append(name)
description = help_text

View File

@ -178,6 +178,7 @@ def test_field_with_choices_gettext():
def test_field_with_choices_collision():
field = models.CharField(help_text='Timezone', choices=(
('Etc/GMT+1+2', 'Fake choice to produce double collision'),
('Etc/GMT+1', 'Greenwich Mean Time +1'),
('Etc/GMT-1', 'Greenwich Mean Time -1'),
))