From 034e6312244cbe24c474267fe70c625d03d7d581 Mon Sep 17 00:00:00 2001 From: Vitaliy Popel <112088383+vitaliypopel@users.noreply.github.com> Date: Sun, 6 Oct 2024 17:38:36 +0300 Subject: [PATCH] Update README.md Added require_http_methods for example --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3659337..e235165 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ router = Router('/app', 'app', auto_trailing_slash=True) # or = Router(prefix='/app', app_name='app', auto_trailing_slash=True) -@router.route('/hello-world') +@router.route('/hello-world', methods=['GET']) def hello_world(request: HttpRequest) -> HttpResponse: return HttpResponse('Hello World!') ``` @@ -65,8 +65,10 @@ urlpatterns = [ ~/project/app/views.py: ```python from django.http import HttpRequest, HttpResponse +from django.views.decorators.http import require_http_methods +@require_http_methods(['GET']) def hello_world(request: HttpRequest) -> HttpResponse: return HttpResponse('Hello World!') ```