how do I a login in from the database? I need to use two elements (user and password) of a table from Bd to perform a login. Someone know the format of what i need to put in models.py, views.py or more specific, the things that i need to do a correct login, thanks.
Unable to authenticate user from oracle database (python 3.8.3 and django 3.0)
165 Views Asked by Jean Miranda Cerda At
2
There are 2 best solutions below
0
On
Django provides authentication ,i recommend checking out the doc .
in the models.py section of your application you can import the built-in User Class in order to have access to login.
use this at the top of your models.py
from django.contrib.auth.models import User
class Post(models.Model):
...
...
author = models.ForeignKey(User)
now you can Create users in the command line for example using:
>>> User.objects.create(username='prozesh', email='[email protected]', password='**********')
you should also use authenticate and login functions to do your job in the views.py section but i strongly recommend reading the doc or this article
Try using django's inbuilt auth functionalities to authenticate logins.
If you want to register new users using "User.objects.create(email,password)"
Refer - auth