mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #29750 -- Added View.setup() hook for class-based views.
This commit is contained in:
committed by
Tim Graham
parent
19e863a844
commit
e671337e8b
@@ -82,11 +82,12 @@ Because Django's URL resolver expects to send the request and associated
|
||||
arguments to a callable function, not a class, class-based views have an
|
||||
:meth:`~django.views.generic.base.View.as_view` class method which returns a
|
||||
function that can be called when a request arrives for a URL matching the
|
||||
associated pattern. The function creates an instance of the class and calls its
|
||||
:meth:`~django.views.generic.base.View.dispatch` method. ``dispatch`` looks at
|
||||
the request to determine whether it is a ``GET``, ``POST``, etc, and relays the
|
||||
request to a matching method if one is defined, or raises
|
||||
:class:`~django.http.HttpResponseNotAllowed` if not::
|
||||
associated pattern. The function creates an instance of the class, calls
|
||||
:meth:`~django.views.generic.base.View.setup` to initialize its attributes, and
|
||||
then calls its :meth:`~django.views.generic.base.View.dispatch` method.
|
||||
``dispatch`` looks at the request to determine whether it is a ``GET``,
|
||||
``POST``, etc, and relays the request to a matching method if one is defined,
|
||||
or raises :class:`~django.http.HttpResponseNotAllowed` if not::
|
||||
|
||||
# urls.py
|
||||
from django.urls import path
|
||||
|
||||
Reference in New Issue
Block a user