MozSecureWorld FAQ: Difference between revisions

(Created page with "= MozSecureWorld FAQ/Notes = == FAQ == === CSRF error === Django's fix to CSRF can be found in [https://docs.djangoproject.com/en/dev/intro/tutorial04/ the tutorial]. Where you p...")
 
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
= MozSecureWorld FAQ/Notes =
= MozSecureWorld FAQ/Notes =
== FAQ ==
=== Browser Cookie error ===
"Your Web browser doesn't appear to have cookies enabled."
[http://curioushq.blogspot.com/2011/07/solved-django-your-web-browser-doesnt.html See solution here.]
 
=== CSRF error ===
=== CSRF error ===
Django's fix to CSRF can be found in [https://docs.djangoproject.com/en/dev/intro/tutorial04/ the tutorial]. Where you put in  
Django's fix to CSRF can be found in [https://docs.djangoproject.com/en/dev/intro/tutorial04/ the tutorial]. Where you put in  
Line 26: Line 29:
<pre>
<pre>
import jingo
import jingo
     rendered = jingo.render(request, 'template.html', {"var_name": var_value})
     return jingo.render(request, 'template.html', {"var_name": var_value})
</pre>
 
 
==== AJAX CSRF 403 error ====
You have to send the csrf token along in ajax.
You can get the csrf token value as:
 
var csrfvalue = $('input[name=csrfmiddlewaretoken]').val();
var sendData = {csrfmiddlewaretoken: csrfvalue, yourName: yourValue};
 
=== HTML is not rendered ===
Solution: Use Django [https://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe |safe]
 
Problem: After using bleach, the safe tags show up "&lt;b&gt;should be bolded&lt;/b&gt;" instead of being rendered as <b>should be bolded</b>, you have to add a "|safe" to the template.html:
<pre>{{richtext.comment|safe}}
</pre>
</pre>
67

edits