def render(self, context): from django.core.urlresolvers import NoReverseMatch from pinax.core.urlresolvers import reverse_full args = [arg.resolve(context) for arg in self.args] kwargs = dict([(smart_str(k,'ascii'), v.resolve(context)) for k, v in list(self.kwargs.items())]) # Try to look up the URL twice: once given the view name, and again # relative to what we guess is the "main" app. If they both fail, # re-raise the NoReverseMatch unless we're using the # {% url ... as var %} construct in which cause return nothing. url = '' try: url = reverse_full(self.view_name, args=args, kwargs=kwargs, current_app=context.current_app) except NoReverseMatch as e: if settings.SETTINGS_MODULE: project_name = settings.SETTINGS_MODULE.split('.')[0] try: url = reverse_full(project_name + '.' + self.view_name, args=args, kwargs=kwargs, current_app=context.current_app) except NoReverseMatch: if self.asvar is None: # Re-raise the original exception, not the one with # the path relative to the project. This makes a # better error message. raise e else: if self.asvar is None: raise e if self.asvar: context[self.asvar] = url return '' else: return url
def get_full_url(self): return reverse_full('wiki_article', kwargs={'title': self.title, }, group=self.group)