i created user -
def login(request):
if request.method == 'POST':
user = auth.authenticate(username=request.POST['username'], password=request.POST['password'])
if user is not None:
auth.login(request,user)
if user.usergroup=='A':
return redirect('pages/page1.html')
else:
return redirect('pages/page2.html')
else:
messages.error(request,'Invalid credentials')
return redirect('login')
# User is authenticate
else:
return render(request,'pages/login.html')
with this i logged in as user1 ,got the error AttributeError at / 'User' object has no attribute 'usergroup' kindly help is there any other code too ?
try this
if user.groups.filter(name='A').exists():
return redirect('pages/page1.html')
else:
return redirect('pages/page2.html')