Ticket #4824: defaults.diff

File defaults.diff, 729 bytes (added by raminf, 17 years ago)

Checking for duplicate URL names (if specified)

  • django/conf/urls/defaults.py

     
    1010
    1111def patterns(prefix, *args):
    1212    pattern_list = []
     13    name_dict = {}
    1314    for t in args:
    1415        if isinstance(t, (list, tuple)):
    1516            t = url(prefix=prefix, *t)
    1617        elif isinstance(t, RegexURLPattern):
    1718            t.add_prefix(prefix)
     19        if hasattr(t, 'name') and t.name:
     20                        if t.name in name_dict:
     21                                raise ImproperlyConfigured('Duplicate named URL specified ("%s")' % t.name)
     22                        else:
     23                                name_dict[t.name] = True
    1824        pattern_list.append(t)
    1925    return pattern_list
    2026
Back to Top