mirror of
https://github.com/jointakahe/takahe.git
synced 2024-12-26 07:10:28 +00:00
18 lines
504 B
Python
18 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()
|