csrf_403.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  5. <meta name="robots" content="NONE,NOARCHIVE">
  6. <title>403 Forbidden</title>
  7. <style type="text/css">
  8. html * { padding:0; margin:0; }
  9. body * { padding:10px 20px; }
  10. body * * { padding:0; }
  11. body { font:small sans-serif; background:#eee; color:#000; }
  12. body>div { border-bottom:1px solid #ddd; }
  13. h1 { font-weight:normal; margin-bottom:.4em; }
  14. h1 span { font-size:60%; color:#666; font-weight:normal; }
  15. #info { background:#f6f6f6; }
  16. #info ul { margin: 0.5em 4em; }
  17. #info p, #summary p { padding-top:10px; }
  18. #summary { background: #ffc; }
  19. #explanation { background:#eee; border-bottom: 0px none; }
  20. </style>
  21. </head>
  22. <body>
  23. <div id="summary">
  24. <h1>{{ title }} <span>(403)</span></h1>
  25. <p>{{ main }}</p>
  26. {% if no_referer %}
  27. <p>{{ no_referer1 }}</p>
  28. <p>{{ no_referer2 }}</p>
  29. <p>{{ no_referer3 }}</p>
  30. {% endif %}
  31. {% if no_cookie %}
  32. <p>{{ no_cookie1 }}</p>
  33. <p>{{ no_cookie2 }}</p>
  34. {% endif %}
  35. </div>
  36. {% if DEBUG %}
  37. <div id="info">
  38. <h2>Help</h2>
  39. {% if reason %}
  40. <p>Reason given for failure:</p>
  41. <pre>
  42. {{ reason }}
  43. </pre>
  44. {% endif %}
  45. <p>In general, this can occur when there is a genuine Cross Site Request Forgery, or when
  46. <a
  47. href="https://docs.djangoproject.com/en/{{ docs_version }}/ref/csrf/">Django’s
  48. CSRF mechanism</a> has not been used correctly. For POST forms, you need to
  49. ensure:</p>
  50. <ul>
  51. <li>Your browser is accepting cookies.</li>
  52. <li>The view function passes a <code>request</code> to the template’s <a
  53. href="https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render"><code>render</code></a>
  54. method.</li>
  55. <li>In the template, there is a <code>{% templatetag openblock %} csrf_token
  56. {% templatetag closeblock %}</code> template tag inside each POST form that
  57. targets an internal URL.</li>
  58. <li>If you are not using <code>CsrfViewMiddleware</code>, then you must use
  59. <code>csrf_protect</code> on any views that use the <code>csrf_token</code>
  60. template tag, as well as those that accept the POST data.</li>
  61. <li>The form has a valid CSRF token. After logging in in another browser
  62. tab or hitting the back button after a login, you may need to reload the
  63. page with the form, because the token is rotated after a login.</li>
  64. </ul>
  65. <p>You’re seeing the help section of this page because you have <code>DEBUG =
  66. True</code> in your Django settings file. Change that to <code>False</code>,
  67. and only the initial error message will be displayed. </p>
  68. <p>You can customize this page using the CSRF_FAILURE_VIEW setting.</p>
  69. </div>
  70. {% else %}
  71. <div id="explanation">
  72. <p><small>{{ more }}</small></p>
  73. </div>
  74. {% endif %}
  75. </body>
  76. </html>