File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 11import django
2+
23try :
34 from django .apps import apps
45except ImportError :
1415
1516class BaseBuilder (object ):
1617 def __init__ (
17- self ,
18- app ,
19- model ,
20- crud
18+ self ,
19+ app ,
20+ model ,
21+ crud
2122 ):
2223
2324 self .model = model
@@ -29,6 +30,9 @@ def __init__(
2930 self .detailview_excludes = self ._has_crud_attr ('detailview_excludes' )
3031 self .createupdate_forms = self ._has_crud_attr ('createupdate_forms' )
3132
33+ self .custom_update_view_mixin = self ._has_crud_attr ('custom_update_view_mixin' )
34+ self .custom_create_view_mixin = self ._has_crud_attr ('custom_create_view_mixin' )
35+
3236 # django tables2
3337 self .custom_table2 = self ._has_crud_attr ('custom_table2' )
3438 self .tables2_fields = self ._has_crud_attr ('tables2_fields' )
Original file line number Diff line number Diff line change @@ -127,9 +127,13 @@ def generate_create_view(self):
127127 custom_postfix_url = self .custom_postfix_url
128128 )
129129
130+ parent_classes = [self .get_createupdate_mixin (), CreateView ]
131+ if self .custom_create_view_mixin :
132+ parent_classes .insert (0 , self .custom_create_view_mixin )
133+
130134 create_class = type (
131135 name ,
132- ( self . get_createupdate_mixin (), CreateView ),
136+ tuple ( parent_classes ),
133137 create_args
134138 )
135139
@@ -172,9 +176,13 @@ def generate_update_view(self):
172176 custom_postfix_url = self .custom_postfix_url
173177 )
174178
179+ parent_classes = [self .get_createupdate_mixin (), UpdateView ]
180+ if self .custom_update_view_mixin :
181+ parent_classes .insert (0 , self .custom_update_view_mixin )
182+
175183 update_class = type (
176184 name ,
177- ( self . get_createupdate_mixin (), UpdateView ),
185+ tuple ( parent_classes ),
178186 update_args
179187 )
180188 self .classes [name ] = update_class
You can’t perform that action at this time.
0 commit comments