Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

URL-encoded URLs in FlatPage.get_absolute_url.

  • Loading branch information...
commit 4b01ee7a50a9bfa88991461bb4a91edc59b48d34 1 parent e4ee3d8
@aaugustin aaugustin authored
View
5 django/contrib/flatpages/models.py
@@ -3,8 +3,7 @@
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 @@ def __str__(self):
return "%s -- %s" % (self.url, self.title)
def get_absolute_url(self):
- return self.url
+ return iri_to_uri(self.url)
View
1  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 *
View
15 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/')
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.