User login and Django OTPExtending the User model with custom fields in DjangoWhat is a “slug” in Django?Django - Set Up A Scheduled Job?How do I do a not equal in Django queryset filtering?Does Django scale?How to debug in Django, the good way?Need a minimal Django file upload exampleHow to check Django versiondifferentiate null=True, blank=True in djangoCannot display HTML string
List, map function based on a condition
A+ rating still unsecure by Google Chrome's opinion
Lípínguapua dopo Pêpê
Did Michelle Obama have a staff of 23; and Melania have a staff of 4?
How do I ask for 2-3 days per week remote work in a job interview?
What should we do with manuals from the 80s?
Some pads on a PCB are marked in clusters and I can't understand which one is which
Setting up a Mathematical Institute of Refereeing?
Is the Microsoft recommendation to use C# properties applicable to game development?
Can the average speed of a moving body be 0?
Is it OK to draw different current from L1 and L2 on NEMA 14-50?
What would it take to get a message to another star?
Good textbook for queueing theory and performance modeling
Illustrator - SVG make thinner path
Weird resistor with dots around it
Why do so many people play out of turn on the last lead?
Are there any low-level means to *exit* the Ethereal plane to a plane of my choosing?
Is there a fallacy about "appeal to 'big words'"?
Are there liquid fueled rocket boosters having coaxial fuel/oxidizer tanks?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
English article "A" vs "The"
Installing Windows to flash UEFI/ BIOS, then reinstalling Ubuntu
How would armour (and combat) change if the fighter didn't need to actually wear it?
When did Bilbo and Frodo learn that Gandalf was a Maia?
User login and Django OTP
Extending the User model with custom fields in DjangoWhat is a “slug” in Django?Django - Set Up A Scheduled Job?How do I do a not equal in Django queryset filtering?Does Django scale?How to debug in Django, the good way?Need a minimal Django file upload exampleHow to check Django versiondifferentiate null=True, blank=True in djangoCannot display HTML string
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want the user to login using three fields, username, password and OTP ONLY.
Here is my .html file
% extends "base.html" %
% load static %
% load bootstrap4 %
% block head %
<title>HomePage</title>
% endblock %
% block content %
<div class="container">
<div style='width:500px;margin:0 auto;' class="panel panel-default">
<div class="panel-body">
<h1>Login</h1>
<form method="POST" class="form">
% csrf_token %
% bootstrap_form form %
% buttons %
<button type="submit" class="btn btn-primary">Login</button>
% endbuttons %
</form>
</div>
</div>
</div>
% endblock %
Here is the browser view of the .html file
I want to remove Otp Device and Otp Challenge as they are unnecessary for my case.
Here is my models.py file
from django.contrib.auth.models import AbstractUser
class ProjectUser(AbstractUser):
# add additional fields in here
def __str__(self):
return self.email
Here is my urls.py file
from django_otp.forms import OTPAuthenticationForm
from django.contrib.auth.views import LoginView
urlpatterns = [
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=OTPAuthenticationForm), name='user_login'), ]
Here is the reference I used
python html django python-3.x one-time-password
add a comment |
I want the user to login using three fields, username, password and OTP ONLY.
Here is my .html file
% extends "base.html" %
% load static %
% load bootstrap4 %
% block head %
<title>HomePage</title>
% endblock %
% block content %
<div class="container">
<div style='width:500px;margin:0 auto;' class="panel panel-default">
<div class="panel-body">
<h1>Login</h1>
<form method="POST" class="form">
% csrf_token %
% bootstrap_form form %
% buttons %
<button type="submit" class="btn btn-primary">Login</button>
% endbuttons %
</form>
</div>
</div>
</div>
% endblock %
Here is the browser view of the .html file
I want to remove Otp Device and Otp Challenge as they are unnecessary for my case.
Here is my models.py file
from django.contrib.auth.models import AbstractUser
class ProjectUser(AbstractUser):
# add additional fields in here
def __str__(self):
return self.email
Here is my urls.py file
from django_otp.forms import OTPAuthenticationForm
from django.contrib.auth.views import LoginView
urlpatterns = [
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=OTPAuthenticationForm), name='user_login'), ]
Here is the reference I used
python html django python-3.x one-time-password
As described in the documentation, you don't need to display those fields in your template, so instead of using% bootstrap_form form %
just render the fields you need yourself. Or subclassOTPAuthenticationForm
and change the widgets for these two fields to beHiddenInput
widgets.
– dirkgroten
Mar 27 at 12:34
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
you can use% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and setotp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same forotp_challenge
.
– dirkgroten
Mar 27 at 13:39
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22
add a comment |
I want the user to login using three fields, username, password and OTP ONLY.
Here is my .html file
% extends "base.html" %
% load static %
% load bootstrap4 %
% block head %
<title>HomePage</title>
% endblock %
% block content %
<div class="container">
<div style='width:500px;margin:0 auto;' class="panel panel-default">
<div class="panel-body">
<h1>Login</h1>
<form method="POST" class="form">
% csrf_token %
% bootstrap_form form %
% buttons %
<button type="submit" class="btn btn-primary">Login</button>
% endbuttons %
</form>
</div>
</div>
</div>
% endblock %
Here is the browser view of the .html file
I want to remove Otp Device and Otp Challenge as they are unnecessary for my case.
Here is my models.py file
from django.contrib.auth.models import AbstractUser
class ProjectUser(AbstractUser):
# add additional fields in here
def __str__(self):
return self.email
Here is my urls.py file
from django_otp.forms import OTPAuthenticationForm
from django.contrib.auth.views import LoginView
urlpatterns = [
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=OTPAuthenticationForm), name='user_login'), ]
Here is the reference I used
python html django python-3.x one-time-password
I want the user to login using three fields, username, password and OTP ONLY.
Here is my .html file
% extends "base.html" %
% load static %
% load bootstrap4 %
% block head %
<title>HomePage</title>
% endblock %
% block content %
<div class="container">
<div style='width:500px;margin:0 auto;' class="panel panel-default">
<div class="panel-body">
<h1>Login</h1>
<form method="POST" class="form">
% csrf_token %
% bootstrap_form form %
% buttons %
<button type="submit" class="btn btn-primary">Login</button>
% endbuttons %
</form>
</div>
</div>
</div>
% endblock %
Here is the browser view of the .html file
I want to remove Otp Device and Otp Challenge as they are unnecessary for my case.
Here is my models.py file
from django.contrib.auth.models import AbstractUser
class ProjectUser(AbstractUser):
# add additional fields in here
def __str__(self):
return self.email
Here is my urls.py file
from django_otp.forms import OTPAuthenticationForm
from django.contrib.auth.views import LoginView
urlpatterns = [
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=OTPAuthenticationForm), name='user_login'), ]
Here is the reference I used
python html django python-3.x one-time-password
python html django python-3.x one-time-password
edited Mar 27 at 17:39
Matthew
asked Mar 27 at 11:37
MatthewMatthew
3454 silver badges20 bronze badges
3454 silver badges20 bronze badges
As described in the documentation, you don't need to display those fields in your template, so instead of using% bootstrap_form form %
just render the fields you need yourself. Or subclassOTPAuthenticationForm
and change the widgets for these two fields to beHiddenInput
widgets.
– dirkgroten
Mar 27 at 12:34
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
you can use% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and setotp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same forotp_challenge
.
– dirkgroten
Mar 27 at 13:39
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22
add a comment |
As described in the documentation, you don't need to display those fields in your template, so instead of using% bootstrap_form form %
just render the fields you need yourself. Or subclassOTPAuthenticationForm
and change the widgets for these two fields to beHiddenInput
widgets.
– dirkgroten
Mar 27 at 12:34
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
you can use% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and setotp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same forotp_challenge
.
– dirkgroten
Mar 27 at 13:39
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22
As described in the documentation, you don't need to display those fields in your template, so instead of using
% bootstrap_form form %
just render the fields you need yourself. Or subclass OTPAuthenticationForm
and change the widgets for these two fields to be HiddenInput
widgets.– dirkgroten
Mar 27 at 12:34
As described in the documentation, you don't need to display those fields in your template, so instead of using
% bootstrap_form form %
just render the fields you need yourself. Or subclass OTPAuthenticationForm
and change the widgets for these two fields to be HiddenInput
widgets.– dirkgroten
Mar 27 at 12:34
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
you can use
% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and set otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same for otp_challenge
.– dirkgroten
Mar 27 at 13:39
you can use
% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and set otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same for otp_challenge
.– dirkgroten
Mar 27 at 13:39
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22
add a comment |
1 Answer
1
active
oldest
votes
Solution 1:
The straight forward way is to Subclass OTPAuthenticationForm
to replace the form fields used for otp_device
and otp_challenge
by using the HiddenInput
widget. In your app folder, create a new python file called forms.py
and add the following
from django_otp.forms import OTPAuthenticationForm
from django import forms
class SimpleOTPAuthenticationForm(OTPAuthenticationForm):
otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
otp_challenge = forms.CharField(required=False, widget=forms.HiddenInput)
In your urls.py
file inside your app, add the import
and replace the LoginView
with the following
from .forms import SimpleOTPAuthenticationForm
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=SimpleOTPAuthenticationForm), name='user_login'),
Solution 2:
Alternative option but requires more styling to fit the bootstrap form warning and other features. Start with using the following
Only display the fields you want in your template: Since otp_device
and otp_challenge
are not required, you can just leave them out. Use % bootstrap_field form.<field> %
for each of the fields you want to display instead of % bootstrap_form form %
. See here for all the options to customise the rendering of each field. Errors for each field can be displayed with form.errors.<field>
but you have to style them yourself.
In your case
% bootstrap_field form.username %
% bootstrap_field form.password %
% bootstrap_field form.otp_token %
For option number one, where is the <field> parameter defined ?% bootstrap_field form.username %
and% bootstrap_field form.password %
works, but where is labels for the fieldsusername
andpassword
in this case located ?
– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376279%2fuser-login-and-django-otp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solution 1:
The straight forward way is to Subclass OTPAuthenticationForm
to replace the form fields used for otp_device
and otp_challenge
by using the HiddenInput
widget. In your app folder, create a new python file called forms.py
and add the following
from django_otp.forms import OTPAuthenticationForm
from django import forms
class SimpleOTPAuthenticationForm(OTPAuthenticationForm):
otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
otp_challenge = forms.CharField(required=False, widget=forms.HiddenInput)
In your urls.py
file inside your app, add the import
and replace the LoginView
with the following
from .forms import SimpleOTPAuthenticationForm
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=SimpleOTPAuthenticationForm), name='user_login'),
Solution 2:
Alternative option but requires more styling to fit the bootstrap form warning and other features. Start with using the following
Only display the fields you want in your template: Since otp_device
and otp_challenge
are not required, you can just leave them out. Use % bootstrap_field form.<field> %
for each of the fields you want to display instead of % bootstrap_form form %
. See here for all the options to customise the rendering of each field. Errors for each field can be displayed with form.errors.<field>
but you have to style them yourself.
In your case
% bootstrap_field form.username %
% bootstrap_field form.password %
% bootstrap_field form.otp_token %
For option number one, where is the <field> parameter defined ?% bootstrap_field form.username %
and% bootstrap_field form.password %
works, but where is labels for the fieldsusername
andpassword
in this case located ?
– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
add a comment |
Solution 1:
The straight forward way is to Subclass OTPAuthenticationForm
to replace the form fields used for otp_device
and otp_challenge
by using the HiddenInput
widget. In your app folder, create a new python file called forms.py
and add the following
from django_otp.forms import OTPAuthenticationForm
from django import forms
class SimpleOTPAuthenticationForm(OTPAuthenticationForm):
otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
otp_challenge = forms.CharField(required=False, widget=forms.HiddenInput)
In your urls.py
file inside your app, add the import
and replace the LoginView
with the following
from .forms import SimpleOTPAuthenticationForm
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=SimpleOTPAuthenticationForm), name='user_login'),
Solution 2:
Alternative option but requires more styling to fit the bootstrap form warning and other features. Start with using the following
Only display the fields you want in your template: Since otp_device
and otp_challenge
are not required, you can just leave them out. Use % bootstrap_field form.<field> %
for each of the fields you want to display instead of % bootstrap_form form %
. See here for all the options to customise the rendering of each field. Errors for each field can be displayed with form.errors.<field>
but you have to style them yourself.
In your case
% bootstrap_field form.username %
% bootstrap_field form.password %
% bootstrap_field form.otp_token %
For option number one, where is the <field> parameter defined ?% bootstrap_field form.username %
and% bootstrap_field form.password %
works, but where is labels for the fieldsusername
andpassword
in this case located ?
– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
add a comment |
Solution 1:
The straight forward way is to Subclass OTPAuthenticationForm
to replace the form fields used for otp_device
and otp_challenge
by using the HiddenInput
widget. In your app folder, create a new python file called forms.py
and add the following
from django_otp.forms import OTPAuthenticationForm
from django import forms
class SimpleOTPAuthenticationForm(OTPAuthenticationForm):
otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
otp_challenge = forms.CharField(required=False, widget=forms.HiddenInput)
In your urls.py
file inside your app, add the import
and replace the LoginView
with the following
from .forms import SimpleOTPAuthenticationForm
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=SimpleOTPAuthenticationForm), name='user_login'),
Solution 2:
Alternative option but requires more styling to fit the bootstrap form warning and other features. Start with using the following
Only display the fields you want in your template: Since otp_device
and otp_challenge
are not required, you can just leave them out. Use % bootstrap_field form.<field> %
for each of the fields you want to display instead of % bootstrap_form form %
. See here for all the options to customise the rendering of each field. Errors for each field can be displayed with form.errors.<field>
but you have to style them yourself.
In your case
% bootstrap_field form.username %
% bootstrap_field form.password %
% bootstrap_field form.otp_token %
Solution 1:
The straight forward way is to Subclass OTPAuthenticationForm
to replace the form fields used for otp_device
and otp_challenge
by using the HiddenInput
widget. In your app folder, create a new python file called forms.py
and add the following
from django_otp.forms import OTPAuthenticationForm
from django import forms
class SimpleOTPAuthenticationForm(OTPAuthenticationForm):
otp_device = forms.CharField(required=False, widget=forms.HiddenInput)
otp_challenge = forms.CharField(required=False, widget=forms.HiddenInput)
In your urls.py
file inside your app, add the import
and replace the LoginView
with the following
from .forms import SimpleOTPAuthenticationForm
path('user_login/', LoginView.as_view(template_name="accounts_app/user_login.html",
authentication_form=SimpleOTPAuthenticationForm), name='user_login'),
Solution 2:
Alternative option but requires more styling to fit the bootstrap form warning and other features. Start with using the following
Only display the fields you want in your template: Since otp_device
and otp_challenge
are not required, you can just leave them out. Use % bootstrap_field form.<field> %
for each of the fields you want to display instead of % bootstrap_form form %
. See here for all the options to customise the rendering of each field. Errors for each field can be displayed with form.errors.<field>
but you have to style them yourself.
In your case
% bootstrap_field form.username %
% bootstrap_field form.password %
% bootstrap_field form.otp_token %
edited Mar 27 at 17:35
Matthew
3454 silver badges20 bronze badges
3454 silver badges20 bronze badges
answered Mar 27 at 15:34
dirkgrotendirkgroten
8,9681 gold badge15 silver badges25 bronze badges
8,9681 gold badge15 silver badges25 bronze badges
For option number one, where is the <field> parameter defined ?% bootstrap_field form.username %
and% bootstrap_field form.password %
works, but where is labels for the fieldsusername
andpassword
in this case located ?
– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
add a comment |
For option number one, where is the <field> parameter defined ?% bootstrap_field form.username %
and% bootstrap_field form.password %
works, but where is labels for the fieldsusername
andpassword
in this case located ?
– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
For option number one, where is the <field> parameter defined ?
% bootstrap_field form.username %
and % bootstrap_field form.password %
works, but where is labels for the fields username
and password
in this case located ?– Matthew
Mar 27 at 16:11
For option number one, where is the <field> parameter defined ?
% bootstrap_field form.username %
and % bootstrap_field form.password %
works, but where is labels for the fields username
and password
in this case located ?– Matthew
Mar 27 at 16:11
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
labels are displayed by default. You can customise a lot (see the docs, I added them to my answer)
– dirkgroten
Mar 27 at 16:14
thank you very much sir
– Matthew
Mar 27 at 17:36
thank you very much sir
– Matthew
Mar 27 at 17:36
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55376279%2fuser-login-and-django-otp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As described in the documentation, you don't need to display those fields in your template, so instead of using
% bootstrap_form form %
just render the fields you need yourself. Or subclassOTPAuthenticationForm
and change the widgets for these two fields to beHiddenInput
widgets.– dirkgroten
Mar 27 at 12:34
@dirkgroten I do want to use bootstrap_form therefore I rather choose the subclass method, Can you kindly show how to do that ?
– Matthew
Mar 27 at 13:32
you can use
% bootstrap_field <field> %
for each of the fields you want to show, that's usually how you customise your form rendering. But if you prefer to change the form fields' widgets, just subclass the form and setotp_device = forms.CharField(required=False, widget=forms.HiddenInput)
and same forotp_challenge
.– dirkgroten
Mar 27 at 13:39
@dirkgroten can you please provide a full answer below so I can mark it :) Thank you
– Matthew
Mar 27 at 15:22