from django.urls.base import reverse def url_by_name(name, request, just_url=False): base_url = reverse(name) if just_url: return base_url else: nxt = request.GET.get('next', request.get_full_path()) return base_url + '?next=%s' % nxt def url_login(request, just_url=False): return url_by_name('users-login', request, just_url) def url_logout(request, just_url=False): return url_by_name('users-logout', request, just_url) def url_profile(request, just_url=False): return url_by_name('users-profile', request, just_url) def url_recover(request, just_url=False): return url_by_name('users-recover', request, just_url) def url_register(request, just_url=False): return url_by_name('users-register', request, just_url)