From 3dbbdbaa45005f1f82162b2035f791e68884c52e Mon Sep 17 00:00:00 2001 From: vitaliypopel Date: Sun, 6 Oct 2024 17:34:00 +0300 Subject: [PATCH] Added methods params for views registration in example app --- examples/example/example_app/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/example/example_app/views.py b/examples/example/example_app/views.py index aef21b0..ec4da3c 100644 --- a/examples/example/example_app/views.py +++ b/examples/example/example_app/views.py @@ -11,7 +11,7 @@ router = Router('example/', 'example_app') -@router.route('') +@router.route('', methods=['GET']) def index(request: HttpRequest) -> HttpResponse: return HttpResponse('''

Index page

@@ -19,7 +19,7 @@ def index(request: HttpRequest) -> HttpResponse: ''') -@router.route('async/', name='async') +@router.route('async/', name='async', methods=['Get']) async def async_view(request: HttpRequest) -> JsonResponse: return JsonResponse( { @@ -29,7 +29,7 @@ async def async_view(request: HttpRequest) -> JsonResponse: ) -@router.route('template/') +@router.route('template/', methods=['get']) class GenericTemplateView(TemplateView): template_name = 'template.html' @@ -39,13 +39,13 @@ def get_context_data(self, **kwargs) -> dict[str, Any]: return context -@router.route('redirect/') +@router.route('redirect/', methods=['GET']) class GenericRedirectView(RedirectView): def get_redirect_url(self, *args, **kwargs) -> str: return reverse('example_app:generic_form') -@router.route('form/') +@router.route('form/', methods=['get', 'post']) class GenericFormView(FormView): form_class = Form template_name = 'form.html' @@ -57,7 +57,7 @@ def form_valid(self, form: Form): )) -@router.route('/') +@router.route('/', methods=['GET']) class HelloView(View): async def get(self, request: HttpRequest, name: str) -> HttpResponse: return HttpResponse(f'''