Skip to content

Commit

Permalink
Use 'force_text', not 'unicode', for compat across python version
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Jul 5, 2013
1 parent 676ab49 commit 8f79caf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def humanize_strptime(format_string):

def strip_multiple_choice_msg(help_text):
"""
Remove the 'Hold down "control" ...' message that is enforced in select
multiple fields.
Remove the 'Hold down "control" ...' message that is Django enforces in
select multiple fields on ModelForms. (Required for 1.5 and earlier)
See https://code.djangoproject.com/ticket/9321
"""
multiple_choice_msg = _(' Hold down "Control", or "Command" on a Mac, to select more than one.')
multiple_choice_msg = unicode(multiple_choice_msg)
multiple_choice_msg = force_text(multiple_choice_msg)

return help_text.replace(multiple_choice_msg, '')

Expand Down
2 changes: 1 addition & 1 deletion rest_framework/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ def test_help_text_no_hold_down_control_msg(self):
message that Django appends to choice fields.
"""
rel_field = fields.Field(help_text=ManyToManyModel._meta.get_field('rel').help_text)
self.assertEqual('Some help text.', unicode(rel_field.help_text))
self.assertEqual('Some help text.', rel_field.help_text)


class AttributeMappingOnAutogeneratedFieldsTests(TestCase):
Expand Down

0 comments on commit 8f79caf

Please sign in to comment.