Reputation: 1
I have a form class where I ask for a username and password. I created my own authenticate function. I simply want to pass the username and password input to the authenticate function. I've tried saving it as self.user/self.pw or passing it directly.
Thanks in advance!
I am using Django lockdown. I don't need to save the username and password to a database because I'm using my own authentication function.
class loginform(forms.Form):
username = forms.CharField ...
password = forms.CharField...
def authenticate(self, request, username, password):
print("this actually prints")
'''authenticate with passed username and password'''
Upvotes: 0
Views: 58
Reputation: 52018
You can access them through cleaned_data
attribute of the class. For example:
class loginform(forms.Form): # Please use PascalCase when defining class name(as per pep-8 style guide)
# rest of the code...
def authenticate(self, request):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')
Upvotes: 0