@register.simple_tag(takes_context=True)
def slugurl(context, slug):
 page = Page.objects.filter(slug=slug).first()
 if page:
  return page.relative_url(context[u'request'].site)
 else:
  return None

@ register . simple_tag ( takes_context = True ) def slugurl ( context , slug ) : page = Page . objects . filter ( slug = slug ) . first ( ) if page : return page . relative_url ( context [ u'request' ] . site ) else : return None
returns the url for the page that has the given slug .