summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-02-24 13:12:41 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-02-24 13:27:13 +0100
commit4b01ee7a50a9bfa88991461bb4a91edc59b48d34 (patch)
tree9767779ce00abfe739c439554c21c343d7bc5fca
parente4ee3d8fcac987bc91ab9c559f39f52949227b76 (diff)
URL-encoded URLs in FlatPage.get_absolute_url.
-rw-r--r--django/contrib/flatpages/models.py5
-rw-r--r--django/contrib/flatpages/tests/__init__.py1
-rw-r--r--django/contrib/flatpages/tests/models.py15
3 files changed, 18 insertions, 3 deletions
diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 3a5b4d6135..7378c8c96b 100644
--- a/django/contrib/flatpages/models.py
+++ b/django/contrib/flatpages/models.py
@@ -3,8 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.contrib.sites.models import Site
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
class FlatPage(models.Model):
@@ -27,4 +26,4 @@ class FlatPage(models.Model):
return "%s -- %s" % (self.url, self.title)
def get_absolute_url(self):
- return self.url
+ return iri_to_uri(self.url)
diff --git a/django/contrib/flatpages/tests/__init__.py b/django/contrib/flatpages/tests/__init__.py
index 5dd5e89dca..0805e9dfd6 100644
--- a/django/contrib/flatpages/tests/__init__.py
+++ b/django/contrib/flatpages/tests/__init__.py
@@ -1,5 +1,6 @@
from django.contrib.flatpages.tests.csrf 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.templatetags import *
from django.contrib.flatpages.tests.views import *
diff --git a/django/contrib/flatpages/tests/models.py b/django/contrib/flatpages/tests/models.py
new file mode 100644
index 0000000000..44666d62b0
--- /dev/null
+++ b/django/contrib/flatpages/tests/models.py
@@ -0,0 +1,15 @@
+# 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/')
+
+