Kaydet (Commit) 4b01ee7a authored tarafından Aymeric Augustin's avatar Aymeric Augustin

URL-encoded URLs in FlatPage.get_absolute_url.

üst e4ee3d8f
...@@ -3,8 +3,7 @@ from __future__ import unicode_literals ...@@ -3,8 +3,7 @@ from __future__ import unicode_literals
from django.db import models from django.db import models
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import iri_to_uri, python_2_unicode_compatible
@python_2_unicode_compatible @python_2_unicode_compatible
class FlatPage(models.Model): class FlatPage(models.Model):
...@@ -27,4 +26,4 @@ class FlatPage(models.Model): ...@@ -27,4 +26,4 @@ class FlatPage(models.Model):
return "%s -- %s" % (self.url, self.title) return "%s -- %s" % (self.url, self.title)
def get_absolute_url(self): def get_absolute_url(self):
return self.url return iri_to_uri(self.url)
from django.contrib.flatpages.tests.csrf import * from django.contrib.flatpages.tests.csrf import *
from django.contrib.flatpages.tests.forms import * from django.contrib.flatpages.tests.forms import *
from django.contrib.flatpages.tests.models import *
from django.contrib.flatpages.tests.middleware import * from django.contrib.flatpages.tests.middleware import *
from django.contrib.flatpages.tests.templatetags import * from django.contrib.flatpages.tests.templatetags import *
from django.contrib.flatpages.tests.views import * from django.contrib.flatpages.tests.views import *
# coding: utf-8
from __future__ import unicode_literals
from django.contrib.flatpages.models import FlatPage
from django.test import TestCase
class FlatpageModelTests(TestCase):
def test_get_absolute_url_urlencodes(self):
pf = FlatPage(title="Café!", url='/café/')
self.assertEqual(pf.get_absolute_url(), '/caf%C3%A9/')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment