def canonical_path(request):
 lang = getattr(request, 'locale', settings.LANGUAGE_CODE)
 url = getattr(request, 'path', '/')
 return {'canonical_path': re.sub(('^/' + lang), '', url)}

def canonical_path ( request ) : lang = getattr ( request , 'locale' , settings . LANGUAGE_CODE ) url = getattr ( request , 'path' , '/' ) return { 'canonical_path' : re . sub ( ( '^/' + lang ) , '' , url ) }
the canonical path can be overridden with a template variable like l10n_utils .