This may seem like a silly question but I can't find anything to help. How would you create a logout button on every view like the one available in the admin page?
Use templates inheritance: https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance or include tag: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#include
Example with template inheritance: We have a base template for all pages on our application:
<html>
<head>...</head>
<body>
<a href="/logout">logout</a> # or use the "url" tag: {% url logout_named_view %}
{% block content %} {% endblock %}
</body>
</html>
{% extends "base.html" %}
{% block content %}
<div class="content">....</div>
....
....
{% endblock %}
Now, we have a logout link on all pages inherited from the base.html
Example with include tag:
<div class="user_panel">
<a href="/logout">logout</a>
</div>
<html>
<head>...</head>
<body>
{% include "user_panel.html" %}
...
...
</body>
</html>
I recommend for a solution to your problem using template inheritance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With