i cant login and after loging i cant redirect to homepage. my code is added below. any idea why?
views.py
def login_view(request):
members = Users.objects.all()
auth = False
if request.method == 'POST':
username = request.POST['username']
password = hashlib.md5(request.POST['password'].encode('utf-8')).hexdigest()
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
return redirect(profile_view)
context = {
'nav': 'APP | Login',
'navoptions': ['registration',]
}
return render(request, 'home-login.html', context=context)
profile view
@login_required
def profile_view(request):
#if request.user.is_authenticated:
id = request.user
context = {
'nav': id,
'user': id,
'option': option,
'navoptions': ['home', 'courses', 'news', 'Sign Out']
}
return render(request, 'profile.html', context=context)
urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path("", login_view, name='home-login'),
path("signup_user/", signup_view, name='registration'),
path("profile/", profile_view, name='profile'),
]
below is what i added in settings.py as mentioned is some online page.
settings.py
LOGIN_REDIRECT_URL = "/"
i think even after i changed the login redirect, its still looking for the default login url.
below is the error i get in the browser: