0👍
✅
This is generally how I would go about it. You can add context if needed.
views.py:
from django.shortcuts import render
def home(request):
if request.user.is_authenticated():
return user_home(request)
else:
return login_home(request)
def user_home(request)
return render(request, 'path/to/user_template.html')
def login_home(request)
return render(request, 'path/to/login_template.html')
1👍
You need simple check in view:
if request.user.is_authenticated():
return HttpResponseRedirect('/profileurl/')
👤ndpu
- [Answered ]-Getting AttributeError while registering my model to Django admin?
- [Answered ]-Invalid literal for int() error in ForeignKey default
- [Answered ]-Python/Django render enumerated list to table
1👍
An easy way to do it would be a redirect to another view:
MyApp.views
def home(request):
if request.user.is_authenticated():
redirect
else:
home page
If you want the actual url entry to load a different template than the home page, or a modified home page, you could just as easily render whatever template you wanted in response to the url request instead of issuing a redirect
- [Answered ]-Use Django Flatpages with TinyMCE
- [Answered ]-Python cant make dictionary from list of dictionaries
Source:stackexchange.com