Answer the question
In order to leave comments, you need to log in
How to fix decorator related bug in django?
Good afternoon! I started to study django and I can't figure out decorators in any way... I can't find anything on the Internet. In general, I would like all get requests to display a void, and all others to display an error 405 The code is below. Thanks in advance!
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.views.decorators.http import require_http_methods, require_GET
# Create your views here.
def index(response):
return HttpResponse('')
@require_http_methods(['GET'])
def req(request):
return HttpResponse()
@require_http_methods(['POST'])
def req(request):
return HttpResponse(staus = 405)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question