mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-29 18:50:59 +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()
|