Ticket #5160: base.3.py.diff

File base.3.py.diff, 910 bytes (added by Esaj, 8 years ago)

Use django.util.http.urlquote for unicode safety

  • django/db/models/base.py

     
    1313from django.utils.datastructures import SortedDict
    1414from django.utils.functional import curry
    1515from django.utils.encoding import smart_str, force_unicode
     16from django.utils.http import urlquote
    1617from django.conf import settings
    1718from itertools import izip
    1819import types
     
    359360    def _get_FIELD_url(self, field):
    360361        if getattr(self, field.attname): # value is not blank
    361362            import urlparse
    362             return urlparse.urljoin(settings.MEDIA_URL, getattr(self, field.attname)).replace('\\', '/')
     363            return urlparse.urljoin(settings.MEDIA_URL, urlquote(getattr(self, field.attname).replace('\\', '/')))
    363364        return ''
    364365
    365366    def _get_FIELD_size(self, field):
Back to Top