misc: call init_stuff() from setup() not dispatch() (#88641)

View.setup() is the proper place to intialize a view, not
View.dispatch() see
https://docs.djangoproject.com/en/5.0/ref/class-based-views/base/#django.views.generic.base.View.setup
This commit is contained in:
Benjamin Dauvergne 2024-03-28 16:09:43 +01:00
parent 1848640469
commit 31f897ded7
1 changed files with 4 additions and 4 deletions

View File

@ -158,6 +158,10 @@ class GenericConnectorMixin:
def get_form_class(self):
return self.model.get_manager_form_class(exclude=self.exclude_fields)
def setup(self, request, *args, **kwargs):
super().setup(request, *args, **kwargs)
self.init_stuff(request, *args, **kwargs)
def init_stuff(self, request, *args, **kwargs):
connector = self.get_connector(**kwargs)
for app in apps.get_app_configs():
@ -170,10 +174,6 @@ class GenericConnectorMixin:
self.model = app.get_connector_model()
def dispatch(self, request, *args, **kwargs):
self.init_stuff(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
class GenericConnectorView(GenericConnectorMixin, DetailView):
def get_context_data(self, slug=None, **kwargs):