How do I create a CSRF token in a flyleaf pop-up, so that the user can post some text in the database with the form Talking? I've added the }); Originally when I leave the token, the sheet map is not fully loaded, but if I leave it , Then I get a missing CSRF token or an incorrect error. I'm a bit new to all this (JavaScript / Leaflets / Web Dev / Diesen) so I'm not sure Person should problem is where is it coming from or introduce me? I think I have to strike around the leaflet.js code, but I do not believe I am able to understand it. Any advice where to go explicitly or to insert some code, or just why the code in code (code) is not much appreciated! You can send by yourself Enjoy {% csrf_token%} tag to a simple HTML form, which works fine, but when I put it in the contents section of the pop-up, it does not work , Although other HTML elements work fine
map.on ('click', function (e) {var popupContent = '& lt; p & gt; what you post to this place LET; form action = "/ post_temp /" method "" post "& gt; {% csrf_token%} & lt; p & gt; input type =" text "name =" post "& gt; & lt; ; / P & gt; Input type = "submit" value = "Post" & gt; & lt; / form & gt; ', popup = new L.Pop (); popup.etlatlng; popup .Set content (popup content); map.open popup );
csrfmiddletto
$ Use the getCookie (name) {post} ("/ view_func /", {yourself_var: yourself_data, csrfmiddletw: getCookie ('Csrftoken'), // or $ .cookie}, function (data) {// handler results} Var cookieValue = null; If (document.cookie & amp; amp; document.cookie! = '') {Var cookies = document.cookie.split (';'); For (var i = 0; i & lt; cookies.length; i ++) {var cookie = jQuery.trim (cookies [i]); // Does this cookie start with the name of the string that we want? If (cookie.substring (0, name.length + 1) == (name + '=')) {cookieValue = decodeurIComponent (cookie.substring (name.length + 1)); break; }}} Return Cookie Value; }
Comments
Post a Comment