Permalink
Browse files

Merge pull request #900 from bmispelon/ticket-20022

Fix #20022: Correctly handle prefixes with url-unsafe characters in reverse()
  • Loading branch information...
2 parents 5d8342f + 4fa7f3c commit 1059da8de675442e84381d6366c0be254681753e @jacobian jacobian committed with apollo13 Mar 13, 2013
@@ -388,7 +388,7 @@ def _reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs):
if len(args) != len(params) + len(prefix_args):
continue
unicode_args = [force_text(val) for val in args]
- candidate = (prefix_norm + result) % dict(zip(prefix_args + params, unicode_args))
+ candidate = (prefix_norm.replace('%', '%%') + result) % dict(zip(prefix_args + params, unicode_args))
else:
if set(kwargs.keys()) | set(defaults.keys()) != set(params) | set(defaults.keys()) | set(prefix_args):
continue
@@ -10,29 +10,16 @@
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
+from shared_models.models import Author, Book
-class Author(models.Model):
- name = models.CharField(max_length=100)
- class Meta:
- ordering = ('name', )
-
-@python_2_unicode_compatible
-class Article(models.Model):
- headline = models.CharField(max_length=100)
- pub_date = models.DateTimeField()
- author = models.ForeignKey(Author, blank=True, null=True)
- class Meta:
- ordering = ('-pub_date', 'headline')
-
- def __str__(self):
- return self.headline
class Tag(models.Model):
- articles = models.ManyToManyField(Article)
+ articles = models.ManyToManyField(Book)
name = models.CharField(max_length=100)
class Meta:
ordering = ('name', )
+
@python_2_unicode_compatible
class Season(models.Model):
year = models.PositiveSmallIntegerField()
@@ -41,6 +28,7 @@ class Season(models.Model):
def __str__(self):
return six.text_type(self.year)
+
@python_2_unicode_compatible
class Game(models.Model):
season = models.ForeignKey(Season, related_name='games')
@@ -50,6 +38,7 @@ class Game(models.Model):
def __str__(self):
return "%s at %s" % (self.away, self.home)
+
@python_2_unicode_compatible
class Player(models.Model):
name = models.CharField(max_length=100)
Oops, something went wrong. Retry.

0 comments on commit 1059da8

Please sign in to comment.