... HttpResponse の代わりに、これらのサブクラスのインスタンスを返してください。例えば: from django.http import HttpResponse , HttpResponseNotFound def my_view ( request ): # ... if foo : return HttpResponseNotFound ( "<h1>Page not found</h1>" ) else : return HttpRespon ... 一般的な HTTP エラーなので、簡単に扱える方法があります。 Http404 例外 class django.http. Http404 エラーを返すときは (例えば HttpResponseNotFound )、エラーページを結果とする HTML を定義する責任があります: return HttpResponseNotFound ( "<h1>Page not found</h1>" ) 利便性 ... ... 、これは django.views.defaults.page_not_found() です。カスタムビューを実装する場合は、 request と exception 引数を受け取り、 HttpResponseNotFound を返すようにしてください。 handler500 handler500 呼び出し可能オブジェクト、もしくはサーバーエラーが発生した場合に呼び出され ... ... anyToManyDescriptor If you implement a custom handler404 view, it must return a response with an HTTP 404 status code. Use HttpResponseNotFound or pass status=404 to the HttpResponse . Otherwise, APPEND_SLASH won't work correctly with DEBUG=False . Features deprecat ... ... onseForbidden (django.http のクラス) HttpResponseGone (django.http のクラス) HttpResponseNotAllowed (django.http のクラス) HttpResponseNotFound (django.http のクラス) HttpResponseNotModified (django.http のクラス) HttpResponsePermanentRedirect (django.http のクラス) ... ... ド304)。 class HttpResponseBadRequest [ソース] HttpResponse と似ていますが、ステータスコードとして 400 を使用します。 class HttpResponseNotFound [ソース] HttpResponse と似ていますが、404 ステータスコードを使用します。 class HttpResponseForbidden [ソース] HttpResponse ... 2026年10月08日