Hello,
I don't understand how implement a form with Metronic. (Signin for exemple).
Template is provided , but how does it configure wiews.py for get and post request?
I don't know how intregrate the code below inside wievs.py.
"""Connexion à la plateforme"""
class LoginPageView(View):
template_name = "authentication/login.html"
form_class = forms.LoginForm
def get(self, request):
form = self.form_class()
message = ""
return render(request, self.template_name, context={"form": form, "message": message})
def post(self, request):
form = self.form_class(request.POST)
if form.is_valid():
user = authenticate(
username=form.cleaned_data["username"],
password=form.cleaned_data["password"],
)
if user is not None:
login(request, user)
return redirect("home")
message = "Identifiants invalides."
return render(request, self.template_name, context={"form": form, "message": message})
"""Déconnexion de la plateforme"""
def logout_user(request):
logout(request)
return redirect("login")
Hi,
No worry. Glad you have solved it.
Thanks
my fault !
I forgot to remove "//" in JS file : //submit.form() => submit.form()