Skip to content

Commit

Permalink
Fix the logout to use a POST (introduced with Django 4.1)
Browse files Browse the repository at this point in the history
Also add an handy command to clear Django cache
  • Loading branch information
daniviga committed Nov 5, 2024
1 parent 5b97535 commit 32785f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ram/portal/templates/includes/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
<li><a class="dropdown-item" href="{% url 'admin:index' %}">Admin</a></li>
<li><a class="dropdown-item" href="{% url 'admin:portal_siteconfiguration_changelist' %}">Site configuration</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="{% url 'admin:logout' %}?next={{ request.path }}">Logout</a></li>
<li>
<form id="logout-form" method="post" action="{% url 'admin:logout' %}?next={{ request.path }}">
{% csrf_token %}
<button class="btn btn-link dropdown-item text-danger" type="submit">Log out</button>
</form>
</li>
</ul>
{% else %}
<a class="nav-link" href="{% url 'admin:login' %}?next={{ request.path }}">Log in</a>
Expand Down
2 changes: 1 addition & 1 deletion ram/ram/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ram.utils import git_suffix

__version__ = "0.13.3"
__version__ = "0.13.4"
__version__ += git_suffix(__file__)
13 changes: 13 additions & 0 deletions ram/ram/management/commands/purge_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.core.cache import cache
from django.core.management.base import BaseCommand, CommandError


class Command(BaseCommand):
help = "Clear the application cache"

def handle(self, *args, **options):
try:
cache.clear()
self.stdout.write(self.style.SUCCESS("Cache cleared"))
except Exception:
raise CommandError("Cache is not active")

0 comments on commit 32785f3

Please sign in to comment.