1

As of Aug 23, 2022 (20 days after 4.1 release), google search could not find the answer...!

So, asking on SO.

TaiwanGrapefruitTea
  • 1,045
  • 2
  • 14
  • 25

1 Answers1

4

There is no built-in form, because the view only requires a POST request (and all POST requests require the CSRF token unless CSRF exempt), not any specific data that a form would submit.

The release notes for Django 4.1 explicitly post this example snippet for a logout POST form disguising as a link:

<form id="logout-form" method="post" action="{% url 'admin:logout' %}">
  {% csrf_token %}
  <button type="submit">{% translate "Log out" %}</button>
</form>
#logout-form {
  display: inline;
}
#logout-form button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
AKX
  • 152,115
  • 15
  • 115
  • 172
  • Thanks, @AKX , for the super quick reply! Actually, I had found this too and the real issue was: why is google not finding this in the release notes? So, I submitted this question hoping that google can find it now... – TaiwanGrapefruitTea Aug 23 '22 at 10:19
  • I guess it depends on your search query and the search bubble you're in. Googling "django 4.1 logout post" gives me the release notes as the second result, with the snippet highlighted... – AKX Aug 23 '22 at 10:22
  • That google query is now the first search result for me, but in the detail below the search result, it's actually pointing me to: ‎What's new in Django 4.1 · ‎CSRF_COOKIE_MASKED... -- which is a different feature and quite far away from the real answer on that page! – TaiwanGrapefruitTea Aug 23 '22 at 10:35
  • One day later: the first search result for that google query is: this SO page! – TaiwanGrapefruitTea Aug 24 '22 at 13:18