Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #4129 -- Pass any prefix setting into url(...) constructions so…

… that

prefixes work with the new syntax and strings for function names.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5086 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f85f1d077a11a4999f2b2a0c8f955fa3e74ea722 1 parent 21d9387
Malcolm Tredinnick malcolmt authored
Showing with 12 additions and 3 deletions.
  1. +4 −3 django/conf/urls/defaults.py
  2. +8 −0 django/core/urlresolvers.py
7 django/conf/urls/defaults.py
View
@@ -11,9 +11,10 @@ def patterns(prefix, *args):
pattern_list = []
for t in args:
if isinstance(t, (list, tuple)):
- pattern_list.append(url(prefix=prefix, *t))
- else:
- pattern_list.append(t)
+ t = url(prefix=prefix, *t)
+ elif isinstance(t, RegexURLPattern):
+ t.add_prefix(prefix)
+ pattern_list.append(t)
return pattern_list
def url(regex, view, kwargs=None, name=None, prefix=''):
8 django/core/urlresolvers.py
View
@@ -102,6 +102,14 @@ def __init__(self, regex, callback, default_args=None, name=None):
self.default_args = default_args or {}
self.name = name
+ def add_prefix(self, prefix):
+ """
+ Adds the prefix string to a string-based callback.
+ """
+ if not prefix or not hasattr(self, '_callback_str'):
+ return
+ self._callback_str = prefix + '.' + self._callback_str
+
def resolve(self, path):
match = self.regex.search(path)
if match:
Please sign in to comment.
Something went wrong with that request. Please try again.