Ticket #4772: urlresolvers_unicode.patch

File urlresolvers_unicode.patch, 1.1 KB (added by alexthreed@…, 17 years ago)
  • django/core/urlresolvers.py

     
    1010from django.http import Http404
    1111from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
    1212from django.utils.encoding import iri_to_uri
     13from django.utils.encoding import force_unicode
    1314from django.utils.functional import memoize
    1415import re
    1516
     
    127128            test_regex = grouped
    128129        # Note we're using re.match here on purpose because the start of
    129130        # to string needs to match.
    130         if not re.match(test_regex + '$', str(value)): # TODO: Unicode?
     131        if not re.match(test_regex + '$', force_unicode(value)):
    131132            raise NoReverseMatch("Value %r didn't match regular expression %r" % (value, test_regex))
    132         return str(value) # TODO: Unicode?
     133        return force_unicode(value)
    133134
    134135class RegexURLPattern(object):
    135136    def __init__(self, regex, callback, default_args=None, name=None):
Back to Top