From 84faeb35f23e8d84798cfe2b9daf6ecd15b24498 Mon Sep 17 00:00:00 2001 From: Michaelyin Date: Thu, 25 Jan 2024 11:57:43 +0800 Subject: [PATCH] update doc --- docs/source/multi-format.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/source/multi-format.md b/docs/source/multi-format.md index 90baf43..194d3fc 100644 --- a/docs/source/multi-format.md +++ b/docs/source/multi-format.md @@ -28,8 +28,8 @@ We can do similar approach with `turbo_helper` ```python from turbo_helper import ( - ResponseFormat, - response_format, + TurboStreamResponse, + respond_to, ) class TaskCreateView(LoginRequiredMixin, CreateView): @@ -39,18 +39,18 @@ class TaskCreateView(LoginRequiredMixin, CreateView): messages.success(request, "Created successfully") with respond_to(request) as resp_format: - if resp_format.html: - return response - if resp_format.turbo_stream: - return TurboStreamResponse( - render_to_string( - "demo_tasks/partial/task_create_success.turbo_stream.html", - context={ - "form": TaskForm(), - }, - request=self.request, - ), - ) + if resp_format.turbo_stream: + return TurboStreamResponse( + render_to_string( + "task_create_success.turbo_stream.html", + context={ + "form": TaskForm(), + }, + request=self.request, + ), + ) + if resp_format.html: + return response ``` Notes: