takahe/users/views/admin/generic.py
2023-01-13 16:12:05 -07:00

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()