diff --git a/requirements.prod.txt b/requirements.prod.txt
index 5278f029..4589eff4 100644
--- a/requirements.prod.txt
+++ b/requirements.prod.txt
@@ -42,7 +42,7 @@ marshmallow==3.18.0
# via environs
packaging==21.3
# via marshmallow
-pygments==2.10.0
+pygments==2.19.1
# via
# django-pygmy
# sphinx
diff --git a/tests/_page_snapshots/fuzzy-klass-detail-old.html b/tests/_page_snapshots/fuzzy-klass-detail-old.html
index fcd531ac..b6317f23 100644
--- a/tests/_page_snapshots/fuzzy-klass-detail-old.html
+++ b/tests/_page_snapshots/fuzzy-klass-detail-old.html
@@ -673,7 +673,7 @@
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
-
38
+ 38
39
40
41
@@ -681,8 +681,8 @@
43
44
45
-46 | def __init__(self, **kwargs):
- """
+46 | def __init__(self, **kwargs):
+ """
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
@@ -690,8 +690,8 @@
# instance, or raise an error.
for key, value in kwargs.items():
setattr(self, key, value)
-
- |
+ |
+
@@ -720,11 +720,11 @@
-
| def _allowed_methods(self):
+ | def _allowed_methods(self):
return [m.upper() for m in self.http_method_names if hasattr(self, m)]
-
- |
+ |
+
@@ -753,7 +753,7 @@
Main entry point for a request-response process.
-
48
+ 48
49
50
51
@@ -782,9 +782,9 @@
74
75
76
-77 | @classonlymethod
-def as_view(cls, **initkwargs):
- """Main entry point for a request-response process."""
+77 | @classonlymethod
+def as_view(cls, **initkwargs):
+ """Main entry point for a request-response process."""
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError(
@@ -795,7 +795,7 @@
raise TypeError("%s() received an invalid keyword %r. as_view "
"only accepts arguments that are already "
"attributes of the class." % (cls.__name__, key))
- def view(request, *args, **kwargs):
+ def view(request, *args, **kwargs):
self = cls(**initkwargs)
self.setup(request, *args, **kwargs)
if not hasattr(self, 'request'):
@@ -812,8 +812,8 @@
# like csrf_exempt from dispatch
update_wrapper(view, cls.dispatch, assigned=())
return view
-
- |
+ |
+
@@ -842,7 +842,7 @@
-
90
+ 90
91
92
93
@@ -850,7 +850,7 @@
95
96
97
-98 | def dispatch(self, request, *args, **kwargs):
+98 | def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
@@ -859,8 +859,8 @@
else:
handler = self.http_method_not_allowed
return handler(request, *args, **kwargs)
-
- |
+ |
+
@@ -889,13 +889,13 @@
If the form is invalid, render the invalid form.
-
59
+ | def form_invalid(self, form):
- """If the form is invalid, render the invalid form."""
+61 | def form_invalid(self, form):
+ """If the form is invalid, render the invalid form."""
return self.render_to_response(self.get_context_data(form=form))
-
- |
+ |
+
@@ -924,13 +924,13 @@
If the form is valid, redirect to the supplied URL.
-
55
+ | def form_valid(self, form):
- """If the form is valid, redirect to the supplied URL."""
+57 | def form_valid(self, form):
+ """If the form is valid, redirect to the supplied URL."""
return HttpResponseRedirect(self.get_success_url())
-
- |
+ |
+
@@ -959,13 +959,13 @@
Handle GET requests: instantiate a blank version of the form.
-
131
+ | def get(self, request, *args, **kwargs):
- """Handle GET requests: instantiate a blank version of the form."""
+133 | def get(self, request, *args, **kwargs):
+ """Handle GET requests: instantiate a blank version of the form."""
return self.render_to_response(self.get_context_data())
-
- |
+ |
+
@@ -998,17 +998,17 @@ FormMixin
Insert the form into the context dict.
-
63
+ | def get_context_data(self, **kwargs):
- """Insert the form into the context dict."""
+67 | def get_context_data(self, **kwargs):
+ """Insert the form into the context dict."""
if 'form' not in kwargs:
kwargs['form'] = self.get_form()
return super().get_context_data(**kwargs)
-
- |
+ |
+
@@ -1022,17 +1022,17 @@ ContextMixin
-
23
+ | def get_context_data(self, **kwargs):
+27 | def get_context_data(self, **kwargs):
kwargs.setdefault('view', self)
if self.extra_context is not None:
kwargs.update(self.extra_context)
return kwargs
-
- |
+ |
+
@@ -1068,17 +1068,17 @@
Return an instance of the form to be used in this view.
-
29
+ | def get_form(self, form_class=None):
- """Return an instance of the form to be used in this view."""
+33 | def get_form(self, form_class=None):
+ """Return an instance of the form to be used in this view."""
if form_class is None:
form_class = self.get_form_class()
return form_class(**self.get_form_kwargs())
-
- |
+ |
+
@@ -1107,13 +1107,13 @@
Return the form class to use.
-
25
+ | def get_form_class(self):
- """Return the form class to use."""
+27 | def get_form_class(self):
+ """Return the form class to use."""
return self.form_class
-
- |
+ |
+
@@ -1142,7 +1142,7 @@
Return the keyword arguments for instantiating the form.
-
35
+ 35
36
37
38
@@ -1153,8 +1153,8 @@
43
44
45
-46 | def get_form_kwargs(self):
- """Return the keyword arguments for instantiating the form."""
+46 | def get_form_kwargs(self):
+ """Return the keyword arguments for instantiating the form."""
kwargs = {
'initial': self.get_initial(),
'prefix': self.get_prefix(),
@@ -1165,8 +1165,8 @@
'files': self.request.FILES,
})
return kwargs
-
- |
+ |
+
@@ -1195,13 +1195,13 @@
Return the initial data to use for forms on this view.
-
17
+ | def get_initial(self):
- """Return the initial data to use for forms on this view."""
+19 | def get_initial(self):
+ """Return the initial data to use for forms on this view."""
return self.initial.copy()
-
- |
+ |
+
@@ -1230,13 +1230,13 @@
Return the prefix to use for forms.
-
21
+ | def get_prefix(self):
- """Return the prefix to use for forms."""
+23 | def get_prefix(self):
+ """Return the prefix to use for forms."""
return self.prefix
-
- |
+ |
+
@@ -1265,17 +1265,17 @@
Return the URL to redirect to after processing a valid form.
-
49
+ | def get_success_url(self):
- """Return the URL to redirect to after processing a valid form."""
+53 | def get_success_url(self):
+ """Return the URL to redirect to after processing a valid form."""
if not self.success_url:
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
return str(self.success_url) # success_url may be lazy
-
- |
+ |
+
@@ -1305,7 +1305,7 @@
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
-
141
+ 141
142
143
144
@@ -1315,8 +1315,8 @@
148
149
150
-151 | def get_template_names(self):
- """
+151 | def get_template_names(self):
+ """
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
"""
@@ -1326,8 +1326,8 @@
"'template_name' or an implementation of 'get_template_names()'")
else:
return [self.template_name]
-
- |
+ |
+
@@ -1356,19 +1356,19 @@
-
100
+ | def http_method_not_allowed(self, request, *args, **kwargs):
+105 | def http_method_not_allowed(self, request, *args, **kwargs):
logger.warning(
'Method Not Allowed (%s): %s', request.method, request.path,
extra={'status_code': 405, 'request': request}
)
return HttpResponseNotAllowed(self._allowed_methods())
-
- |
+ |
+
@@ -1397,19 +1397,19 @@
Handle responding to requests for the OPTIONS HTTP verb.
-
107
+ | def options(self, request, *args, **kwargs):
- """Handle responding to requests for the OPTIONS HTTP verb."""
+112 | def options(self, request, *args, **kwargs):
+ """Handle responding to requests for the OPTIONS HTTP verb."""
response = HttpResponse()
response.headers['Allow'] = ', '.join(self._allowed_methods())
response.headers['Content-Length'] = '0'
return response
-
- |
+ |
+
@@ -1439,7 +1439,7 @@
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
-
135
+ 135
136
137
138
@@ -1448,8 +1448,8 @@
141
142
143
-144 | def post(self, request, *args, **kwargs):
- """
+144 | def post(self, request, *args, **kwargs):
+ """
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
"""
@@ -1458,8 +1458,8 @@
return self.form_valid(form)
else:
return self.form_invalid(form)
-
- |
+ |
+
@@ -1488,11 +1488,11 @@
-
| def put(self, *args, **kwargs):
+ | def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
-
- |
+ |
+
@@ -1524,7 +1524,7 @@
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
-
125
+ 125
126
127
128
@@ -1537,8 +1537,8 @@
135
136
137
-138 | def render_to_response(self, context, **response_kwargs):
- """
+138 | def render_to_response(self, context, **response_kwargs):
+ """
Return a response, using the `response_class` for this view, with a
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
@@ -1551,8 +1551,8 @@
using=self.template_engine,
**response_kwargs
)
-
- |
+ |
+
@@ -1581,21 +1581,21 @@
Initialize attributes shared by all view methods.
-
82
+ | def setup(self, request, *args, **kwargs):
- """Initialize attributes shared by all view methods."""
+88 | def setup(self, request, *args, **kwargs):
+ """Initialize attributes shared by all view methods."""
if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get
self.request = request
self.args = args
self.kwargs = kwargs
-
- |
+ |
+
diff --git a/tests/_page_snapshots/fuzzy-klass-detail.html b/tests/_page_snapshots/fuzzy-klass-detail.html
index c64becb8..1761d459 100644
--- a/tests/_page_snapshots/fuzzy-klass-detail.html
+++ b/tests/_page_snapshots/fuzzy-klass-detail.html
@@ -673,7 +673,7 @@
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
-
37
+ 37
38
39
40
@@ -681,8 +681,8 @@
42
43
44
-45 | def __init__(self, **kwargs):
- """
+45 | def __init__(self, **kwargs):
+ """
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
@@ -690,8 +690,8 @@
# instance, or raise an error.
for key, value in kwargs.items():
setattr(self, key, value)
-
- |
+ |
+
@@ -720,11 +720,11 @@
-
| def _allowed_methods(self):
+ | def _allowed_methods(self):
return [m.upper() for m in self.http_method_names if hasattr(self, m)]
-
- |
+ |
+
@@ -753,7 +753,7 @@
Main entry point for a request-response process.
-
47
+ 47
48
49
50
@@ -786,9 +786,9 @@
77
78
79
-80 | @classonlymethod
-def as_view(cls, **initkwargs):
- """Main entry point for a request-response process."""
+80 | @classonlymethod
+def as_view(cls, **initkwargs):
+ """Main entry point for a request-response process."""
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError(
@@ -799,7 +799,7 @@
raise TypeError("%s() received an invalid keyword %r. as_view "
"only accepts arguments that are already "
"attributes of the class." % (cls.__name__, key))
- def view(request, *args, **kwargs):
+ def view(request, *args, **kwargs):
self = cls(**initkwargs)
self.setup(request, *args, **kwargs)
if not hasattr(self, 'request'):
@@ -820,8 +820,8 @@
# the dispatch method.
view.__dict__.update(cls.dispatch.__dict__)
return view
-
- |
+ |
+
@@ -850,7 +850,7 @@
-
93
+ 93
94
95
96
@@ -858,7 +858,7 @@
98
99
100
-101 | def dispatch(self, request, *args, **kwargs):
+101 | def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
@@ -867,8 +867,8 @@
else:
handler = self.http_method_not_allowed
return handler(request, *args, **kwargs)
-
- |
+ |
+
@@ -897,13 +897,13 @@
If the form is invalid, render the invalid form.
-
61
+ | def form_invalid(self, form):
- """If the form is invalid, render the invalid form."""
+63 | def form_invalid(self, form):
+ """If the form is invalid, render the invalid form."""
return self.render_to_response(self.get_context_data(form=form))
-
- |
+ |
+
@@ -932,13 +932,13 @@
If the form is valid, redirect to the supplied URL.
-
57
+ | def form_valid(self, form):
- """If the form is valid, redirect to the supplied URL."""
+59 | def form_valid(self, form):
+ """If the form is valid, redirect to the supplied URL."""
return HttpResponseRedirect(self.get_success_url())
-
- |
+ |
+
@@ -967,13 +967,13 @@
Handle GET requests: instantiate a blank version of the form.
-
133
+ | def get(self, request, *args, **kwargs):
- """Handle GET requests: instantiate a blank version of the form."""
+135 | def get(self, request, *args, **kwargs):
+ """Handle GET requests: instantiate a blank version of the form."""
return self.render_to_response(self.get_context_data())
-
- |
+ |
+
@@ -1006,17 +1006,17 @@ FormMixin
Insert the form into the context dict.
-
65
+ | def get_context_data(self, **kwargs):
- """Insert the form into the context dict."""
+69 | def get_context_data(self, **kwargs):
+ """Insert the form into the context dict."""
if 'form' not in kwargs:
kwargs['form'] = self.get_form()
return super().get_context_data(**kwargs)
-
- |
+ |
+
@@ -1030,17 +1030,17 @@ ContextMixin
-
22
+ | def get_context_data(self, **kwargs):
+26 | def get_context_data(self, **kwargs):
kwargs.setdefault('view', self)
if self.extra_context is not None:
kwargs.update(self.extra_context)
return kwargs
-
- |
+ |
+
@@ -1076,17 +1076,17 @@
Return an instance of the form to be used in this view.
-
31
+ | def get_form(self, form_class=None):
- """Return an instance of the form to be used in this view."""
+35 | def get_form(self, form_class=None):
+ """Return an instance of the form to be used in this view."""
if form_class is None:
form_class = self.get_form_class()
return form_class(**self.get_form_kwargs())
-
- |
+ |
+
@@ -1115,13 +1115,13 @@
Return the form class to use.
-
27
+ | def get_form_class(self):
- """Return the form class to use."""
+29 | def get_form_class(self):
+ """Return the form class to use."""
return self.form_class
-
- |
+ |
+
@@ -1150,7 +1150,7 @@
Return the keyword arguments for instantiating the form.
-
37
+ 37
38
39
40
@@ -1161,8 +1161,8 @@
45
46
47
-48 | def get_form_kwargs(self):
- """Return the keyword arguments for instantiating the form."""
+48 | def get_form_kwargs(self):
+ """Return the keyword arguments for instantiating the form."""
kwargs = {
'initial': self.get_initial(),
'prefix': self.get_prefix(),
@@ -1173,8 +1173,8 @@
'files': self.request.FILES,
})
return kwargs
-
- |
+ |
+
@@ -1203,13 +1203,13 @@
Return the initial data to use for forms on this view.
-
19
+ | def get_initial(self):
- """Return the initial data to use for forms on this view."""
+21 | def get_initial(self):
+ """Return the initial data to use for forms on this view."""
return self.initial.copy()
-
- |
+ |
+
@@ -1238,13 +1238,13 @@
Return the prefix to use for forms.
-
23
+ | def get_prefix(self):
- """Return the prefix to use for forms."""
+25 | def get_prefix(self):
+ """Return the prefix to use for forms."""
return self.prefix
-
- |
+ |
+
@@ -1273,17 +1273,17 @@
Return the URL to redirect to after processing a valid form.
-
51
+ | def get_success_url(self):
- """Return the URL to redirect to after processing a valid form."""
+55 | def get_success_url(self):
+ """Return the URL to redirect to after processing a valid form."""
if not self.success_url:
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
return str(self.success_url) # success_url may be lazy
-
- |
+ |
+
@@ -1313,7 +1313,7 @@
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
-
144
+ 144
145
146
147
@@ -1323,8 +1323,8 @@
151
152
153
-154 | def get_template_names(self):
- """
+154 | def get_template_names(self):
+ """
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
"""
@@ -1334,8 +1334,8 @@
"'template_name' or an implementation of 'get_template_names()'")
else:
return [self.template_name]
-
- |
+ |
+
@@ -1364,19 +1364,19 @@
-
103
+ | def http_method_not_allowed(self, request, *args, **kwargs):
+108 | def http_method_not_allowed(self, request, *args, **kwargs):
logger.warning(
'Method Not Allowed (%s): %s', request.method, request.path,
extra={'status_code': 405, 'request': request}
)
return HttpResponseNotAllowed(self._allowed_methods())
-
- |
+ |
+
@@ -1405,19 +1405,19 @@
Handle responding to requests for the OPTIONS HTTP verb.
-
110
+ | def options(self, request, *args, **kwargs):
- """Handle responding to requests for the OPTIONS HTTP verb."""
+115 | def options(self, request, *args, **kwargs):
+ """Handle responding to requests for the OPTIONS HTTP verb."""
response = HttpResponse()
response.headers['Allow'] = ', '.join(self._allowed_methods())
response.headers['Content-Length'] = '0'
return response
-
- |
+ |
+
@@ -1447,7 +1447,7 @@
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
-
137
+ 137
138
139
140
@@ -1456,8 +1456,8 @@
143
144
145
-146 | def post(self, request, *args, **kwargs):
- """
+146 | def post(self, request, *args, **kwargs):
+ """
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
"""
@@ -1466,8 +1466,8 @@
return self.form_valid(form)
else:
return self.form_invalid(form)
-
- |
+ |
+
@@ -1496,11 +1496,11 @@
-
| def put(self, *args, **kwargs):
+ | def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
-
- |
+ |
+
@@ -1532,7 +1532,7 @@
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
-
128
+ 128
129
130
131
@@ -1545,8 +1545,8 @@
138
139
140
-141 | def render_to_response(self, context, **response_kwargs):
- """
+141 | def render_to_response(self, context, **response_kwargs):
+ """
Return a response, using the `response_class` for this view, with a
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
@@ -1559,8 +1559,8 @@
using=self.template_engine,
**response_kwargs
)
-
- |
+ |
+
@@ -1589,21 +1589,21 @@
Initialize attributes shared by all view methods.
-
85
+ | def setup(self, request, *args, **kwargs):
- """Initialize attributes shared by all view methods."""
+91 | def setup(self, request, *args, **kwargs):
+ """Initialize attributes shared by all view methods."""
if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get
self.request = request
self.args = args
self.kwargs = kwargs
-
- |
+ |
+
diff --git a/tests/_page_snapshots/klass-detail-old.html b/tests/_page_snapshots/klass-detail-old.html
index d2d0f4c9..aa994913 100644
--- a/tests/_page_snapshots/klass-detail-old.html
+++ b/tests/_page_snapshots/klass-detail-old.html
@@ -669,7 +669,7 @@
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
-
38
+ 38
39
40
41
@@ -677,8 +677,8 @@
43
44
45
-46 | def __init__(self, **kwargs):
- """
+46 | def __init__(self, **kwargs):
+ """
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
@@ -686,8 +686,8 @@
# instance, or raise an error.
for key, value in kwargs.items():
setattr(self, key, value)
-
- |
+ |
+
@@ -716,11 +716,11 @@
-
| def _allowed_methods(self):
+ | def _allowed_methods(self):
return [m.upper() for m in self.http_method_names if hasattr(self, m)]
-
- |
+ |
+
@@ -749,7 +749,7 @@
Main entry point for a request-response process.
-
48
+ 48
49
50
51
@@ -778,9 +778,9 @@
74
75
76
-77 | @classonlymethod
-def as_view(cls, **initkwargs):
- """Main entry point for a request-response process."""
+77 | @classonlymethod
+def as_view(cls, **initkwargs):
+ """Main entry point for a request-response process."""
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError(
@@ -791,7 +791,7 @@
raise TypeError("%s() received an invalid keyword %r. as_view "
"only accepts arguments that are already "
"attributes of the class." % (cls.__name__, key))
- def view(request, *args, **kwargs):
+ def view(request, *args, **kwargs):
self = cls(**initkwargs)
self.setup(request, *args, **kwargs)
if not hasattr(self, 'request'):
@@ -808,8 +808,8 @@
# like csrf_exempt from dispatch
update_wrapper(view, cls.dispatch, assigned=())
return view
-
- |
+ |
+
@@ -838,7 +838,7 @@
-
90
+ 90
91
92
93
@@ -846,7 +846,7 @@
95
96
97
-98 | def dispatch(self, request, *args, **kwargs):
+98 | def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
@@ -855,8 +855,8 @@
else:
handler = self.http_method_not_allowed
return handler(request, *args, **kwargs)
-
- |
+ |
+
@@ -885,13 +885,13 @@
If the form is invalid, render the invalid form.
-
59
+ | def form_invalid(self, form):
- """If the form is invalid, render the invalid form."""
+61 | def form_invalid(self, form):
+ """If the form is invalid, render the invalid form."""
return self.render_to_response(self.get_context_data(form=form))
-
- |
+ |
+
@@ -920,13 +920,13 @@
If the form is valid, redirect to the supplied URL.
-
55
+ | def form_valid(self, form):
- """If the form is valid, redirect to the supplied URL."""
+57 | def form_valid(self, form):
+ """If the form is valid, redirect to the supplied URL."""
return HttpResponseRedirect(self.get_success_url())
-
- |
+ |
+
@@ -955,13 +955,13 @@
Handle GET requests: instantiate a blank version of the form.
-
131
+ | def get(self, request, *args, **kwargs):
- """Handle GET requests: instantiate a blank version of the form."""
+133 | def get(self, request, *args, **kwargs):
+ """Handle GET requests: instantiate a blank version of the form."""
return self.render_to_response(self.get_context_data())
-
- |
+ |
+
@@ -994,17 +994,17 @@ FormMixin
Insert the form into the context dict.
-
63
+ | def get_context_data(self, **kwargs):
- """Insert the form into the context dict."""
+67 | def get_context_data(self, **kwargs):
+ """Insert the form into the context dict."""
if 'form' not in kwargs:
kwargs['form'] = self.get_form()
return super().get_context_data(**kwargs)
-
- |
+ |
+
@@ -1018,17 +1018,17 @@ ContextMixin
-
23
+ | def get_context_data(self, **kwargs):
+27 | def get_context_data(self, **kwargs):
kwargs.setdefault('view', self)
if self.extra_context is not None:
kwargs.update(self.extra_context)
return kwargs
-
- |
+ |
+
@@ -1064,17 +1064,17 @@
Return an instance of the form to be used in this view.
-
29
+ | def get_form(self, form_class=None):
- """Return an instance of the form to be used in this view."""
+33 | def get_form(self, form_class=None):
+ """Return an instance of the form to be used in this view."""
if form_class is None:
form_class = self.get_form_class()
return form_class(**self.get_form_kwargs())
-
- |
+ |
+
@@ -1103,13 +1103,13 @@
Return the form class to use.
-
25
+ | def get_form_class(self):
- """Return the form class to use."""
+27 | def get_form_class(self):
+ """Return the form class to use."""
return self.form_class
-
- |
+ |
+
@@ -1138,7 +1138,7 @@
Return the keyword arguments for instantiating the form.
-
35
+ 35
36
37
38
@@ -1149,8 +1149,8 @@
43
44
45
-46 | def get_form_kwargs(self):
- """Return the keyword arguments for instantiating the form."""
+46 | def get_form_kwargs(self):
+ """Return the keyword arguments for instantiating the form."""
kwargs = {
'initial': self.get_initial(),
'prefix': self.get_prefix(),
@@ -1161,8 +1161,8 @@
'files': self.request.FILES,
})
return kwargs
-
- |
+ |
+
@@ -1191,13 +1191,13 @@
Return the initial data to use for forms on this view.
-
17
+ | def get_initial(self):
- """Return the initial data to use for forms on this view."""
+19 | def get_initial(self):
+ """Return the initial data to use for forms on this view."""
return self.initial.copy()
-
- |
+ |
+
@@ -1226,13 +1226,13 @@
Return the prefix to use for forms.
-
21
+ | def get_prefix(self):
- """Return the prefix to use for forms."""
+23 | def get_prefix(self):
+ """Return the prefix to use for forms."""
return self.prefix
-
- |
+ |
+
@@ -1261,17 +1261,17 @@
Return the URL to redirect to after processing a valid form.
-
49
+ | def get_success_url(self):
- """Return the URL to redirect to after processing a valid form."""
+53 | def get_success_url(self):
+ """Return the URL to redirect to after processing a valid form."""
if not self.success_url:
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
return str(self.success_url) # success_url may be lazy
-
- |
+ |
+
@@ -1301,7 +1301,7 @@
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
-
141
+ 141
142
143
144
@@ -1311,8 +1311,8 @@
148
149
150
-151 | def get_template_names(self):
- """
+151 | def get_template_names(self):
+ """
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
"""
@@ -1322,8 +1322,8 @@
"'template_name' or an implementation of 'get_template_names()'")
else:
return [self.template_name]
-
- |
+ |
+
@@ -1352,19 +1352,19 @@
-
100
+ | def http_method_not_allowed(self, request, *args, **kwargs):
+105 | def http_method_not_allowed(self, request, *args, **kwargs):
logger.warning(
'Method Not Allowed (%s): %s', request.method, request.path,
extra={'status_code': 405, 'request': request}
)
return HttpResponseNotAllowed(self._allowed_methods())
-
- |
+ |
+
@@ -1393,19 +1393,19 @@
Handle responding to requests for the OPTIONS HTTP verb.
-
107
+ | def options(self, request, *args, **kwargs):
- """Handle responding to requests for the OPTIONS HTTP verb."""
+112 | def options(self, request, *args, **kwargs):
+ """Handle responding to requests for the OPTIONS HTTP verb."""
response = HttpResponse()
response.headers['Allow'] = ', '.join(self._allowed_methods())
response.headers['Content-Length'] = '0'
return response
-
- |
+ |
+
@@ -1435,7 +1435,7 @@
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
-
135
+ 135
136
137
138
@@ -1444,8 +1444,8 @@
141
142
143
-144 | def post(self, request, *args, **kwargs):
- """
+144 | def post(self, request, *args, **kwargs):
+ """
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
"""
@@ -1454,8 +1454,8 @@
return self.form_valid(form)
else:
return self.form_invalid(form)
-
- |
+ |
+
@@ -1484,11 +1484,11 @@
-
| def put(self, *args, **kwargs):
+ | def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
-
- |
+ |
+
@@ -1520,7 +1520,7 @@
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
-
125
+ 125
126
127
128
@@ -1533,8 +1533,8 @@
135
136
137
-138 | def render_to_response(self, context, **response_kwargs):
- """
+138 | def render_to_response(self, context, **response_kwargs):
+ """
Return a response, using the `response_class` for this view, with a
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
@@ -1547,8 +1547,8 @@
using=self.template_engine,
**response_kwargs
)
-
- |
+ |
+
@@ -1577,21 +1577,21 @@
Initialize attributes shared by all view methods.
-
82
+ | def setup(self, request, *args, **kwargs):
- """Initialize attributes shared by all view methods."""
+88 | def setup(self, request, *args, **kwargs):
+ """Initialize attributes shared by all view methods."""
if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get
self.request = request
self.args = args
self.kwargs = kwargs
-
- |
+ |
+
diff --git a/tests/_page_snapshots/klass-detail.html b/tests/_page_snapshots/klass-detail.html
index dd2b7947..6565802b 100644
--- a/tests/_page_snapshots/klass-detail.html
+++ b/tests/_page_snapshots/klass-detail.html
@@ -669,7 +669,7 @@
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
-
37
+ 37
38
39
40
@@ -677,8 +677,8 @@
42
43
44
-45 | def __init__(self, **kwargs):
- """
+45 | def __init__(self, **kwargs):
+ """
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
@@ -686,8 +686,8 @@
# instance, or raise an error.
for key, value in kwargs.items():
setattr(self, key, value)
-
- |
+ |
+
@@ -716,11 +716,11 @@
-
| def _allowed_methods(self):
+ | def _allowed_methods(self):
return [m.upper() for m in self.http_method_names if hasattr(self, m)]
-
- |
+ |
+
@@ -749,7 +749,7 @@
Main entry point for a request-response process.
-
47
+ 47
48
49
50
@@ -782,9 +782,9 @@
77
78
79
-80 | @classonlymethod
-def as_view(cls, **initkwargs):
- """Main entry point for a request-response process."""
+80 | @classonlymethod
+def as_view(cls, **initkwargs):
+ """Main entry point for a request-response process."""
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError(
@@ -795,7 +795,7 @@
raise TypeError("%s() received an invalid keyword %r. as_view "
"only accepts arguments that are already "
"attributes of the class." % (cls.__name__, key))
- def view(request, *args, **kwargs):
+ def view(request, *args, **kwargs):
self = cls(**initkwargs)
self.setup(request, *args, **kwargs)
if not hasattr(self, 'request'):
@@ -816,8 +816,8 @@
# the dispatch method.
view.__dict__.update(cls.dispatch.__dict__)
return view
-
- |
+ |
+
@@ -846,7 +846,7 @@
-
93
+ 93
94
95
96
@@ -854,7 +854,7 @@
98
99
100
-101 | def dispatch(self, request, *args, **kwargs):
+101 | def dispatch(self, request, *args, **kwargs):
# Try to dispatch to the right method; if a method doesn't exist,
# defer to the error handler. Also defer to the error handler if the
# request method isn't on the approved list.
@@ -863,8 +863,8 @@
else:
handler = self.http_method_not_allowed
return handler(request, *args, **kwargs)
-
- |
+ |
+
@@ -893,13 +893,13 @@
If the form is invalid, render the invalid form.
-
61
+ | def form_invalid(self, form):
- """If the form is invalid, render the invalid form."""
+63 | def form_invalid(self, form):
+ """If the form is invalid, render the invalid form."""
return self.render_to_response(self.get_context_data(form=form))
-
- |
+ |
+
@@ -928,13 +928,13 @@
If the form is valid, redirect to the supplied URL.
-
57
+ | def form_valid(self, form):
- """If the form is valid, redirect to the supplied URL."""
+59 | def form_valid(self, form):
+ """If the form is valid, redirect to the supplied URL."""
return HttpResponseRedirect(self.get_success_url())
-
- |
+ |
+
@@ -963,13 +963,13 @@
Handle GET requests: instantiate a blank version of the form.
-
133
+ | def get(self, request, *args, **kwargs):
- """Handle GET requests: instantiate a blank version of the form."""
+135 | def get(self, request, *args, **kwargs):
+ """Handle GET requests: instantiate a blank version of the form."""
return self.render_to_response(self.get_context_data())
-
- |
+ |
+
@@ -1002,17 +1002,17 @@ FormMixin
Insert the form into the context dict.
-
65
+ | def get_context_data(self, **kwargs):
- """Insert the form into the context dict."""
+69 | def get_context_data(self, **kwargs):
+ """Insert the form into the context dict."""
if 'form' not in kwargs:
kwargs['form'] = self.get_form()
return super().get_context_data(**kwargs)
-
- |
+ |
+
@@ -1026,17 +1026,17 @@ ContextMixin
-
22
+ | def get_context_data(self, **kwargs):
+26 | def get_context_data(self, **kwargs):
kwargs.setdefault('view', self)
if self.extra_context is not None:
kwargs.update(self.extra_context)
return kwargs
-
- |
+ |
+
@@ -1072,17 +1072,17 @@
Return an instance of the form to be used in this view.
-
31
+ | def get_form(self, form_class=None):
- """Return an instance of the form to be used in this view."""
+35 | def get_form(self, form_class=None):
+ """Return an instance of the form to be used in this view."""
if form_class is None:
form_class = self.get_form_class()
return form_class(**self.get_form_kwargs())
-
- |
+ |
+
@@ -1111,13 +1111,13 @@
Return the form class to use.
-
27
+ | def get_form_class(self):
- """Return the form class to use."""
+29 | def get_form_class(self):
+ """Return the form class to use."""
return self.form_class
-
- |
+ |
+
@@ -1146,7 +1146,7 @@
Return the keyword arguments for instantiating the form.
-
37
+ 37
38
39
40
@@ -1157,8 +1157,8 @@
45
46
47
-48 | def get_form_kwargs(self):
- """Return the keyword arguments for instantiating the form."""
+48 | def get_form_kwargs(self):
+ """Return the keyword arguments for instantiating the form."""
kwargs = {
'initial': self.get_initial(),
'prefix': self.get_prefix(),
@@ -1169,8 +1169,8 @@
'files': self.request.FILES,
})
return kwargs
-
- |
+ |
+
@@ -1199,13 +1199,13 @@
Return the initial data to use for forms on this view.
-
19
+ | def get_initial(self):
- """Return the initial data to use for forms on this view."""
+21 | def get_initial(self):
+ """Return the initial data to use for forms on this view."""
return self.initial.copy()
-
- |
+ |
+
@@ -1234,13 +1234,13 @@
Return the prefix to use for forms.
-
23
+ | def get_prefix(self):
- """Return the prefix to use for forms."""
+25 | def get_prefix(self):
+ """Return the prefix to use for forms."""
return self.prefix
-
- |
+ |
+
@@ -1269,17 +1269,17 @@
Return the URL to redirect to after processing a valid form.
-
51
+ | def get_success_url(self):
- """Return the URL to redirect to after processing a valid form."""
+55 | def get_success_url(self):
+ """Return the URL to redirect to after processing a valid form."""
if not self.success_url:
raise ImproperlyConfigured("No URL to redirect to. Provide a success_url.")
return str(self.success_url) # success_url may be lazy
-
- |
+ |
+
@@ -1309,7 +1309,7 @@
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
-
144
+ 144
145
146
147
@@ -1319,8 +1319,8 @@
151
152
153
-154 | def get_template_names(self):
- """
+154 | def get_template_names(self):
+ """
Return a list of template names to be used for the request. Must return
a list. May not be called if render_to_response() is overridden.
"""
@@ -1330,8 +1330,8 @@
"'template_name' or an implementation of 'get_template_names()'")
else:
return [self.template_name]
-
- |
+ |
+
@@ -1360,19 +1360,19 @@
-
103
+ | def http_method_not_allowed(self, request, *args, **kwargs):
+108 | def http_method_not_allowed(self, request, *args, **kwargs):
logger.warning(
'Method Not Allowed (%s): %s', request.method, request.path,
extra={'status_code': 405, 'request': request}
)
return HttpResponseNotAllowed(self._allowed_methods())
-
- |
+ |
+
@@ -1401,19 +1401,19 @@
Handle responding to requests for the OPTIONS HTTP verb.
-
110
+ | def options(self, request, *args, **kwargs):
- """Handle responding to requests for the OPTIONS HTTP verb."""
+115 | def options(self, request, *args, **kwargs):
+ """Handle responding to requests for the OPTIONS HTTP verb."""
response = HttpResponse()
response.headers['Allow'] = ', '.join(self._allowed_methods())
response.headers['Content-Length'] = '0'
return response
-
- |
+ |
+
@@ -1443,7 +1443,7 @@
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
-
137
+ 137
138
139
140
@@ -1452,8 +1452,8 @@
143
144
145
-146 | def post(self, request, *args, **kwargs):
- """
+146 | def post(self, request, *args, **kwargs):
+ """
Handle POST requests: instantiate a form instance with the passed
POST variables and then check if it's valid.
"""
@@ -1462,8 +1462,8 @@
return self.form_valid(form)
else:
return self.form_invalid(form)
-
- |
+ |
+
@@ -1492,11 +1492,11 @@
-
| def put(self, *args, **kwargs):
+ | def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
-
- |
+ |
+
@@ -1528,7 +1528,7 @@
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
-
128
+ 128
129
130
131
@@ -1541,8 +1541,8 @@
138
139
140
-141 | def render_to_response(self, context, **response_kwargs):
- """
+141 | def render_to_response(self, context, **response_kwargs):
+ """
Return a response, using the `response_class` for this view, with a
template rendered with the given context.
Pass response_kwargs to the constructor of the response class.
@@ -1555,8 +1555,8 @@
using=self.template_engine,
**response_kwargs
)
-
- |
+ |
+
@@ -1585,21 +1585,21 @@
Initialize attributes shared by all view methods.
-
85
+ | def setup(self, request, *args, **kwargs):
- """Initialize attributes shared by all view methods."""
+91 | def setup(self, request, *args, **kwargs):
+ """Initialize attributes shared by all view methods."""
if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get
self.request = request
self.args = args
self.kwargs = kwargs
-
- |
+ |
+