I need to add custom file upload handler in admin add and change view (using django 3.2). And getting an error.
So far I created custom FileUploadHandler and trying to add to request in my ModelAdmin. Created class in my appadmin.py
@admin.register(MyClass)
class MyClassAdmin(ModelAdmin):
def get_urls(self):
urls = super().get_urls()
custom_urls = [
url('^my_view/$', self.create_model_view, name='my_view'),
]
return custom_urls + urls
@csrf_exempt
def create_model_view(self, request):
request.upload_handlers = [CustomUploadHandler(request)]
return super().changeform_view(request)
And getting error You cannot set the upload handlers after the upload has been processed.
What am i doing wrong? Where request is started processing?