Answer the question
In order to leave comments, you need to log in
Want a custom form in Django? Am I doing the right thing?
I want the form for authorization to be like this
if I display the form in Django, it is like this I
thought how to do it simply, I do it this way
I use jQuery on the site
I will make such a js file so that
when you click on the login button, a post request is sent for authorization
Get csrf like this and send login and password like this
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
function zapros() {
var username = $( ".username").val();
var parol = $( ".password").val();
var csrftoken = getCookie('csrftoken');
data = {'csrfmiddlewaretoken': csrftoken, username: username, password: parol };
$.ajax({
url: '/линк ту логин форм/',
type: "POST",
data: data
}) ;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question