web.mixins.CustomActionMixin module

Module with web.mixins.CustomActionMixin.

class web.mixins.CustomActionMixin.CustomActionMixin[source]

Bases: object

Mixin to provide action button handling for views.

To register handlers for the different actions define a viewclass method handle_action that creates the appropriate response to a action post request.

_handler_method_prefix: Final[str] = 'handle_'

The name prefix of methods considered request handlers.

post(request)[source]

Creates response to a post request.

If no action matches the existing handlers, responds with Http204. Should be executed last in a custom view post method.

Parameters:

request (HttpRequest) – The post request to handle.

Return type:

HttpResponse

Returns:

The handlers response to the request. If no matching handler is found Http204.

Raises:

ImproperlyConfigured – If the called handler method does not return a django.http.HttpResponse.>