Django login with custom form template












1














I'm using the Django authentication with my login form in my template, after i pressed the login button on the form the page refreshed but doesn't log me in and doesn't show the {{context}} error in the template.



My view:



def login_view(request):
if request.method == 'POST':
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts)
else:
context = 'wrong username or password'
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts,context=context)


My form (header.html)



<div class="col-md-3 top-info-cart text-right mt-lg-4">
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}.</p>
<p><a href="{% url 'frontend:logout' %}">logout</a></p>
{% else %}
<ul class="cart-inner-info">
<li class="button-log">
<a class="btn-open" href="#">
<span class="fa fa-user" aria-hidden="true"></span>
</a>
</li>
</ul>
<p>{{context}}</p>
{% endif %}

<!---->
<div class="overlay-login text-left">
<button type="button" class="overlay-close1">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<div class="wrap">
<h5 class="text-center mb-4">Login Now</h5>
<div class="login p-5 bg-dark mx-auto mw-100">
<form action="{% url 'frontend:login' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="mb-2">User name</label>
<input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your informations with anyone else.</small>
</div>
<div class="form-group">
<label class="mb-2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"type="password">
</div>
<button type="submit" class="btn btn-primary submit mb-4" value="Login">Sign In</button>
<p>Don't have an account? <a href="{% url 'frontend:signup' %}" style="color: orange;">SIGN UP </a></p>
</form>
</div>
<!---->
</div>
</div>


And my urls.py:



from  django.urls import path
from .import views
app_name = 'frontend'
urlpatterns = [
#index
path('',views.index, name='index'),
#/discount/id
path('<id>/',views.single,name='single'),
#/category/category_name
path('category/<name>',views.category,name='category'),
#/signup
path('signup',views.signup,name='signup'),
#/logout
path('logout',views.logout,name='logout'),
#/login
path('login',views.login_view,name='login')
]


It's because of my authentication is wrong or my view function ? i been trying to fix this but still haven't figure it out. Hope someone can help me :)










share|improve this question
























  • I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
    – Abijith Mg
    Nov 21 at 7:27












  • im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
    – Zerontelli
    Nov 21 at 7:34










  • yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
    – Abijith Mg
    Nov 21 at 7:36
















1














I'm using the Django authentication with my login form in my template, after i pressed the login button on the form the page refreshed but doesn't log me in and doesn't show the {{context}} error in the template.



My view:



def login_view(request):
if request.method == 'POST':
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts)
else:
context = 'wrong username or password'
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts,context=context)


My form (header.html)



<div class="col-md-3 top-info-cart text-right mt-lg-4">
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}.</p>
<p><a href="{% url 'frontend:logout' %}">logout</a></p>
{% else %}
<ul class="cart-inner-info">
<li class="button-log">
<a class="btn-open" href="#">
<span class="fa fa-user" aria-hidden="true"></span>
</a>
</li>
</ul>
<p>{{context}}</p>
{% endif %}

<!---->
<div class="overlay-login text-left">
<button type="button" class="overlay-close1">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<div class="wrap">
<h5 class="text-center mb-4">Login Now</h5>
<div class="login p-5 bg-dark mx-auto mw-100">
<form action="{% url 'frontend:login' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="mb-2">User name</label>
<input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your informations with anyone else.</small>
</div>
<div class="form-group">
<label class="mb-2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"type="password">
</div>
<button type="submit" class="btn btn-primary submit mb-4" value="Login">Sign In</button>
<p>Don't have an account? <a href="{% url 'frontend:signup' %}" style="color: orange;">SIGN UP </a></p>
</form>
</div>
<!---->
</div>
</div>


And my urls.py:



from  django.urls import path
from .import views
app_name = 'frontend'
urlpatterns = [
#index
path('',views.index, name='index'),
#/discount/id
path('<id>/',views.single,name='single'),
#/category/category_name
path('category/<name>',views.category,name='category'),
#/signup
path('signup',views.signup,name='signup'),
#/logout
path('logout',views.logout,name='logout'),
#/login
path('login',views.login_view,name='login')
]


It's because of my authentication is wrong or my view function ? i been trying to fix this but still haven't figure it out. Hope someone can help me :)










share|improve this question
























  • I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
    – Abijith Mg
    Nov 21 at 7:27












  • im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
    – Zerontelli
    Nov 21 at 7:34










  • yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
    – Abijith Mg
    Nov 21 at 7:36














1












1








1







I'm using the Django authentication with my login form in my template, after i pressed the login button on the form the page refreshed but doesn't log me in and doesn't show the {{context}} error in the template.



My view:



def login_view(request):
if request.method == 'POST':
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts)
else:
context = 'wrong username or password'
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts,context=context)


My form (header.html)



<div class="col-md-3 top-info-cart text-right mt-lg-4">
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}.</p>
<p><a href="{% url 'frontend:logout' %}">logout</a></p>
{% else %}
<ul class="cart-inner-info">
<li class="button-log">
<a class="btn-open" href="#">
<span class="fa fa-user" aria-hidden="true"></span>
</a>
</li>
</ul>
<p>{{context}}</p>
{% endif %}

<!---->
<div class="overlay-login text-left">
<button type="button" class="overlay-close1">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<div class="wrap">
<h5 class="text-center mb-4">Login Now</h5>
<div class="login p-5 bg-dark mx-auto mw-100">
<form action="{% url 'frontend:login' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="mb-2">User name</label>
<input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your informations with anyone else.</small>
</div>
<div class="form-group">
<label class="mb-2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"type="password">
</div>
<button type="submit" class="btn btn-primary submit mb-4" value="Login">Sign In</button>
<p>Don't have an account? <a href="{% url 'frontend:signup' %}" style="color: orange;">SIGN UP </a></p>
</form>
</div>
<!---->
</div>
</div>


And my urls.py:



from  django.urls import path
from .import views
app_name = 'frontend'
urlpatterns = [
#index
path('',views.index, name='index'),
#/discount/id
path('<id>/',views.single,name='single'),
#/category/category_name
path('category/<name>',views.category,name='category'),
#/signup
path('signup',views.signup,name='signup'),
#/logout
path('logout',views.logout,name='logout'),
#/login
path('login',views.login_view,name='login')
]


It's because of my authentication is wrong or my view function ? i been trying to fix this but still haven't figure it out. Hope someone can help me :)










share|improve this question















I'm using the Django authentication with my login form in my template, after i pressed the login button on the form the page refreshed but doesn't log me in and doesn't show the {{context}} error in the template.



My view:



def login_view(request):
if request.method == 'POST':
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts)
else:
context = 'wrong username or password'
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts,context=context)


My form (header.html)



<div class="col-md-3 top-info-cart text-right mt-lg-4">
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}.</p>
<p><a href="{% url 'frontend:logout' %}">logout</a></p>
{% else %}
<ul class="cart-inner-info">
<li class="button-log">
<a class="btn-open" href="#">
<span class="fa fa-user" aria-hidden="true"></span>
</a>
</li>
</ul>
<p>{{context}}</p>
{% endif %}

<!---->
<div class="overlay-login text-left">
<button type="button" class="overlay-close1">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<div class="wrap">
<h5 class="text-center mb-4">Login Now</h5>
<div class="login p-5 bg-dark mx-auto mw-100">
<form action="{% url 'frontend:login' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="mb-2">User name</label>
<input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your informations with anyone else.</small>
</div>
<div class="form-group">
<label class="mb-2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"type="password">
</div>
<button type="submit" class="btn btn-primary submit mb-4" value="Login">Sign In</button>
<p>Don't have an account? <a href="{% url 'frontend:signup' %}" style="color: orange;">SIGN UP </a></p>
</form>
</div>
<!---->
</div>
</div>


And my urls.py:



from  django.urls import path
from .import views
app_name = 'frontend'
urlpatterns = [
#index
path('',views.index, name='index'),
#/discount/id
path('<id>/',views.single,name='single'),
#/category/category_name
path('category/<name>',views.category,name='category'),
#/signup
path('signup',views.signup,name='signup'),
#/logout
path('logout',views.logout,name='logout'),
#/login
path('login',views.login_view,name='login')
]


It's because of my authentication is wrong or my view function ? i been trying to fix this but still haven't figure it out. Hope someone can help me :)







python django login






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 9:27









Daniel Roseman

443k41574629




443k41574629










asked Nov 21 at 6:53









Zerontelli

848




848












  • I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
    – Abijith Mg
    Nov 21 at 7:27












  • im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
    – Zerontelli
    Nov 21 at 7:34










  • yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
    – Abijith Mg
    Nov 21 at 7:36


















  • I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
    – Abijith Mg
    Nov 21 at 7:27












  • im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
    – Zerontelli
    Nov 21 at 7:34










  • yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
    – Abijith Mg
    Nov 21 at 7:36
















I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
– Abijith Mg
Nov 21 at 7:27






I would suggest you to use breakpoint(python3) or pdb(Python2) to stop the execution at user = authenticate(request, username=username, password=password) and explore on whats happening!
– Abijith Mg
Nov 21 at 7:27














im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
– Zerontelli
Nov 21 at 7:34




im fairly new to Django so it's import import pdb; pdb.set_trace() and breakpoint() after authentication ? cause i cant connect to the website after i added it
– Zerontelli
Nov 21 at 7:34












yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
– Abijith Mg
Nov 21 at 7:36




yes. Once you have applied that statements, the control will stop at that location. Later use realpython.com/python-debugging-pdb to understand how u need to debug
– Abijith Mg
Nov 21 at 7:36












1 Answer
1






active

oldest

votes


















-1














Try changing your form's action to action="":



<form action="" method="post">


The way you have it set right now what I think is happening is your form is just re rendering the login view.



Add a form to your view:



def login_view(request):
if request.method == 'POST':
form = YourLoginForm(data=request.POST)
if form.is_valid():
...


and you can just render your form in the template:



<form action="" method="post">

{{ form.as_p }}
<input type="submit" value="submit"/>

</form>


Also a potential problem is your view's redirect:



return redirect('/'


In my app this would redirect me to my login page because my home view redirects to my login page. Maybe try redirecting to another view upon successful login.






share|improve this answer























  • you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
    – Zerontelli
    Nov 21 at 7:35










  • @Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
    – Whodini
    Nov 21 at 7:40










  • @Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
    – Whodini
    Nov 21 at 7:41










  • so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
    – Zerontelli
    Nov 21 at 8:02










  • This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
    – Daniel Roseman
    Nov 21 at 9:25











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406679%2fdjango-login-with-custom-form-template%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









-1














Try changing your form's action to action="":



<form action="" method="post">


The way you have it set right now what I think is happening is your form is just re rendering the login view.



Add a form to your view:



def login_view(request):
if request.method == 'POST':
form = YourLoginForm(data=request.POST)
if form.is_valid():
...


and you can just render your form in the template:



<form action="" method="post">

{{ form.as_p }}
<input type="submit" value="submit"/>

</form>


Also a potential problem is your view's redirect:



return redirect('/'


In my app this would redirect me to my login page because my home view redirects to my login page. Maybe try redirecting to another view upon successful login.






share|improve this answer























  • you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
    – Zerontelli
    Nov 21 at 7:35










  • @Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
    – Whodini
    Nov 21 at 7:40










  • @Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
    – Whodini
    Nov 21 at 7:41










  • so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
    – Zerontelli
    Nov 21 at 8:02










  • This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
    – Daniel Roseman
    Nov 21 at 9:25
















-1














Try changing your form's action to action="":



<form action="" method="post">


The way you have it set right now what I think is happening is your form is just re rendering the login view.



Add a form to your view:



def login_view(request):
if request.method == 'POST':
form = YourLoginForm(data=request.POST)
if form.is_valid():
...


and you can just render your form in the template:



<form action="" method="post">

{{ form.as_p }}
<input type="submit" value="submit"/>

</form>


Also a potential problem is your view's redirect:



return redirect('/'


In my app this would redirect me to my login page because my home view redirects to my login page. Maybe try redirecting to another view upon successful login.






share|improve this answer























  • you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
    – Zerontelli
    Nov 21 at 7:35










  • @Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
    – Whodini
    Nov 21 at 7:40










  • @Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
    – Whodini
    Nov 21 at 7:41










  • so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
    – Zerontelli
    Nov 21 at 8:02










  • This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
    – Daniel Roseman
    Nov 21 at 9:25














-1












-1








-1






Try changing your form's action to action="":



<form action="" method="post">


The way you have it set right now what I think is happening is your form is just re rendering the login view.



Add a form to your view:



def login_view(request):
if request.method == 'POST':
form = YourLoginForm(data=request.POST)
if form.is_valid():
...


and you can just render your form in the template:



<form action="" method="post">

{{ form.as_p }}
<input type="submit" value="submit"/>

</form>


Also a potential problem is your view's redirect:



return redirect('/'


In my app this would redirect me to my login page because my home view redirects to my login page. Maybe try redirecting to another view upon successful login.






share|improve this answer














Try changing your form's action to action="":



<form action="" method="post">


The way you have it set right now what I think is happening is your form is just re rendering the login view.



Add a form to your view:



def login_view(request):
if request.method == 'POST':
form = YourLoginForm(data=request.POST)
if form.is_valid():
...


and you can just render your form in the template:



<form action="" method="post">

{{ form.as_p }}
<input type="submit" value="submit"/>

</form>


Also a potential problem is your view's redirect:



return redirect('/'


In my app this would redirect me to my login page because my home view redirects to my login page. Maybe try redirecting to another view upon successful login.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 at 0:51

























answered Nov 21 at 7:27









Whodini

49913




49913












  • you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
    – Zerontelli
    Nov 21 at 7:35










  • @Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
    – Whodini
    Nov 21 at 7:40










  • @Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
    – Whodini
    Nov 21 at 7:41










  • so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
    – Zerontelli
    Nov 21 at 8:02










  • This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
    – Daniel Roseman
    Nov 21 at 9:25


















  • you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
    – Zerontelli
    Nov 21 at 7:35










  • @Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
    – Whodini
    Nov 21 at 7:40










  • @Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
    – Whodini
    Nov 21 at 7:41










  • so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
    – Zerontelli
    Nov 21 at 8:02










  • This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
    – Daniel Roseman
    Nov 21 at 9:25
















you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
– Zerontelli
Nov 21 at 7:35




you mean to this ? <form action="" method="post"> but how will the form use the login function in view ?
– Zerontelli
Nov 21 at 7:35












@Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
– Whodini
Nov 21 at 7:40




@Zerontelli - you should have an authentication form. Import it and you can use it in the view. You should also look into using Django's built in authentication system. See this post - simpleisbetterthancomplex.com/tutorial/2016/06/27/…
– Whodini
Nov 21 at 7:40












@Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
– Whodini
Nov 21 at 7:41




@Zerontelli - Yes make the action as I said. The form will know what to do based on your calling it in the view function.
– Whodini
Nov 21 at 7:41












so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
– Zerontelli
Nov 21 at 8:02




so i have to create a form.py and use it to render ? i though i could just use the html file form to send the login data
– Zerontelli
Nov 21 at 8:02












This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
– Daniel Roseman
Nov 21 at 9:25




This is unfortunately a bad answer. There was nothing wrong with the form action, and it is perfectly possible to process the POST data without a form; that is not where the problem is.
– Daniel Roseman
Nov 21 at 9:25


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406679%2fdjango-login-with-custom-form-template%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'