turbo_response.views
#
Module Contents#
Classes#
Renders a simple turbo-stream view |
|
Renders response template inside <turbo-stream> tags. |
|
Mixin for handling form validation. Ensures response |
|
Mixin for handling form validation. Ensures response |
|
Mixin for handling form validation. Ensures response |
|
Returns a turbo stream when form is invalid. |
|
Returns a turbo stream when form is invalid. |
|
Returns a turbo stream when form is invalid. |
|
Handles a delete action, returning an empty turbo-stream "remove" |
|
Retuns a simple turbo-frame response. |
|
Renders response template inside <turbo-frame> tags. |
- class turbo_response.views.TurboStreamView#
Bases:
turbo_response.mixins.TurboStreamResponseMixin
,django.views.generic.View
Renders a simple turbo-stream view
- dispatch(*args, **kwargs)#
- Return type:
django.http.HttpResponse
- class turbo_response.views.TurboStreamTemplateView#
Bases:
turbo_response.mixins.TurboStreamTemplateResponseMixin
,django.views.generic.TemplateView
Renders response template inside <turbo-stream> tags.
- render_to_response(context, **response_kwargs)#
- Parameters:
context (Dict[str, Any]) –
- Return type:
django.http.HttpResponse
- class turbo_response.views.TurboFormView#
Bases:
turbo_response.mixins.TurboFormMixin
,django.views.generic.FormView
Mixin for handling form validation. Ensures response has 422 status on invalid and 303 on success
- class turbo_response.views.TurboCreateView#
Bases:
turbo_response.mixins.TurboFormMixin
,django.views.generic.CreateView
Mixin for handling form validation. Ensures response has 422 status on invalid and 303 on success
- class turbo_response.views.TurboUpdateView#
Bases:
turbo_response.mixins.TurboFormMixin
,django.views.generic.UpdateView
Mixin for handling form validation. Ensures response has 422 status on invalid and 303 on success
- class turbo_response.views.TurboStreamFormView#
Bases:
turbo_response.mixins.TurboStreamFormMixin
,django.views.generic.FormView
Returns a turbo stream when form is invalid.
You should define a partial template corresponding to the template used to render the initial form, for example if your template is posts/post_form.html your partial template is posts/_post_form.html.
The template should then be included in the form:
{% include "_post_form.html" %}
The form or container element should have an ID: this is provided as turbo_stream_target in the template context:
<form method="POST" action=".." id="{{ turbo_stream_target }}">
When the form is posted, if the form is invalid a turbo-stream element wrapping the partial content will be returned, including any validation errors.
- class turbo_response.views.TurboStreamCreateView#
Bases:
turbo_response.mixins.TurboStreamFormModelMixin
,django.views.generic.CreateView
Returns a turbo stream when form is invalid.
You should define a partial template corresponding to the template used to render the initial form, for example if your template is posts/post_form.html your partial template is posts/_post_form.html.
The template should then be included in the form:
{% include "_post_form.html" %}
The form or container element should have an ID: this is provided as turbo_stream_target in the template context:
<form method="POST" action=".." id="{{ turbo_stream_target }}">
When the form is posted, if the form is invalid a turbo-stream element wrapping the partial content will be returned, including any validation errors.
- class turbo_response.views.TurboStreamUpdateView#
Bases:
turbo_response.mixins.TurboStreamFormModelMixin
,django.views.generic.UpdateView
Returns a turbo stream when form is invalid.
You should define a partial template corresponding to the template used to render the initial form, for example if your template is posts/post_form.html your partial template is posts/_post_form.html.
The template should then be included in the form:
{% include "_post_form.html" %}
The form or container element should have an ID: this is provided as turbo_stream_target in the template context:
<form method="POST" action=".." id="{{ turbo_stream_target }}">
When the form is posted, if the form is invalid a turbo-stream element wrapping the partial content will be returned, including any validation errors.
- class turbo_response.views.TurboStreamDeleteView#
Bases:
turbo_response.mixins.TurboStreamResponseMixin
,django.views.generic.detail.SingleObjectMixin
,django.views.generic.View
Handles a delete action, returning an empty turbo-stream “remove” response. The target will be automatically resolved as {model_name}-{PK}.
- turbo_stream_action#
- get_turbo_stream_target()#
Returns the turbo-stream target parameter
- Returns:
turbo-stream target
- Return type:
Optional[str]
- post(request, *args, **kwargs)#
- Parameters:
request (django.http.HttpRequest) –
- Return type:
django.http.HttpResponse
- delete(request, *args, **kwargs)#
- Parameters:
request (django.http.HttpRequest) –
- Return type:
django.http.HttpResponse
- class turbo_response.views.TurboFrameView#
Bases:
turbo_response.mixins.TurboFrameResponseMixin
,django.views.generic.View
Retuns a simple turbo-frame response.
- dispatch(*args, **kwargs)#
- Return type:
django.http.HttpResponse
- class turbo_response.views.TurboFrameTemplateView#
Bases:
turbo_response.mixins.TurboFrameTemplateResponseMixin
,django.views.generic.TemplateView
Renders response template inside <turbo-frame> tags.
- render_to_response(context, **response_kwargs)#
- Parameters:
context (Dict[str, Any]) –
- Return type:
django.http.HttpResponse