from django.http import HttpResponse
from django.shortcuts import render,redirect, get_list_or_404, get_object_or_404
from .models import Users
from .forms import UsersForm
from django.contrib.auth import authenticate
# Create your views here.
def login(request):
#Username = request.POST.get(‘username’)
#password = request.POST.get(‘password’)
form = UsersForm(request.POST or None)
if form.is_valid():
form.save()
form = UsersForm()
return redirect('/product/itemlist')
user = authenticate(username='username', password='password')
if user is not None:
# redirect to homepage
return redirect('/product/itemlist')
else:
# display login again
return render(request, 'users/login.html', {'form':form})
This is my view page when i runserver it takes me to login page then the problem start when i enter my credintials and try to log in
Page not found (404) Request Method: POST Request URL: http://127.0.0.1:8000/users/login/index.html Using the URLconf defined in mazwefuneral.urls, Django tried these URL patterns, in this order:
admin/ product/ users/ login/ [name='login'] main/ accounts/
The current path, users/login/index.html, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
This is the error am getting