mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 16:51:00 +00:00
8b3106b852
Fixes #377
17 lines
504 B
Python
17 lines
504 B
Python
from django.views.generic import View
|
|
from django.views.generic.detail import SingleObjectMixin
|
|
from django_htmx.http import HttpResponseClientRefresh
|
|
|
|
|
|
class HTMXActionView(SingleObjectMixin, View):
|
|
"""
|
|
Generic view that performs an action when called via HTMX and then causes
|
|
a full page refresh.
|
|
"""
|
|
|
|
def post(self, request, pk):
|
|
self.action(self.get_object())
|
|
return HttpResponseClientRefresh()
|
|
|
|
def action(self, instance):
|
|
raise NotImplementedError()
|