After the user logs in i want to redirect to the view ('profile:profile_view')
settings.py
LOGIN_REDIRECT_URL = 'profile:profile_view'
I tried the above code but was not getting the result that i needed because iam passing slug into the url
urls.py
url(r'^(?P<slug>[-\w\d]+)/$', ProfileView.as_view(), name='view_profile'),
from here i tried the following.
settings.py
LOGIN_REDIRECT_URL = 'login_redirect'
urls.py
@login_required
def login_redirect(request):
return redirect('profile:profile_view', pk=request.user.pk, name=request.user.username)
Now i do get the username in the terminal but how do i use the username for the following 'localhost:8000/username'
views.py
class ProfileView(DetailView):
template_name = "profile/profile_view.html"
queryset = User.objects.all()
context_object_name = 'profile'
What am i doing wrong here? is there a better way?