Hi
I've running from trunk and recently switched to the NFA-branch. I found
that the URL templatetag is unhelpful when failing to match a url. I patched
my own copy of the function URLNode in django.template.defaulttags to return
a more helpful error message instead of a empty string. Should I file a
ticket with the patch or should I add the solution as a django snippet
instead? Sorry, if this is a stupid question, but I'm new to this. I
modified the last 3 lines of the function below.


class URLNode(Node):
    def __init__(self, view_name, args, kwargs):
        self.view_name = view_name
        self.args = args
        self.kwargs = kwargs

    def render(self, context):
        from django.core.urlresolvers import reverse, NoReverseMatch
        args = [arg.resolve(context) for arg in self.args]
        kwargs = dict([(smart_str(k,'ascii'), v.resolve(context))
                       for k, v in self.kwargs.items()])
        try:
            return reverse(self.view_name, args=args, kwargs=kwargs)
        except NoReverseMatch:
            try:
                project_name = settings.SETTINGS_MODULE.split('.')[0]
                return reverse(project_name + '.' + self.view_name,
                               args=args, kwargs=kwargs)
            except NoReverseMatch:
                if settings.DEBUG:
                    return u"/NOURLMATCH %s %s %s" % (self.view_name,
args.__str__(), kwargs.__str__())
                return ""

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to