I have been trying to display html templates of Login and Register for an ecommerce website, using Django Framework and Python as server side scripting language. I want to make sure that If Users logs in using its email address and password then It should be redirected to its dashboard. New User has to first register then that user is allowed to login.
I’m done with the backend coding of the templates, but now able to display UI first so that I can try to login from html template and the desired result should be display in default database of the Django. How I can do this?
2
Answers
Your question isn’t very clear so I’ll try to respond to parts of it I understand. To create template html files, make a folder called template and put html files inside of it. Make sure to define the path to templates in your settings.py.
For login/register html pages, create them as .html files inside of templates and then define the url patterns in urls.py.
For the code to make login/register work, you need functions in views.py. This is an example I found on the internet:
Follow @daviid’s advice. Here you will find a link with several tutorials for the authentication system with Django.
I would like to add that if you want your user to log in only with email and password without username you must create a CustomUser model.
moreover, it is recommended by Django himself from version 1.7 onwards
Tutorials link
@absurdity9’s post seems to take into account that you don’t have the Customuser model, in fact if you don’t enter the username, you don’t go ahead . If you don’t want to delve deeper into the topic, follow it.