Ticket #16701: formmixin.diff

File formmixin.diff, 737 bytes (added by wilfred@…, 4 years ago)

Adding an init method to FormMixin so .initial is an instance attribute

1[1mdiff --git a/django/views/generic/edit.py b/django/views/generic/edit.py[m
2[1mindex 3cade52..f1f7d9f 100644[m
3[1m--- a/django/views/generic/edit.py[m
4[1m+++ b/django/views/generic/edit.py[m
5[36m@@ -11,10 +11,13 @@[m [mclass FormMixin(object):[m
6     A mixin that provides a way to show and handle a form in a request.[m
7     """[m
8 [m
9[31m-    initial = {}[m
10     form_class = None[m
11     success_url = None[m
12 [m
13[32m+[m[32m    def __init__(self, *args, **kwargs):[m
14[32m+[m[32m        self.initial = {}[m
15[32m+[m[32m        super(FormMixin, self).__init__(*args, **kwargs)[m
17     def get_initial(self):[m
18         """[m
19         Returns the initial data to use for forms on this view.[m
Back to Top