我想在 StackedInline 的表单集中向我的表单传递一个请求。我现在有:
from django.contrib import admin
from django.utils.functional import curry
class AlbumInline(admin.StackedInline):
form = AlbumAdminForm
model = Album
extra = 1
def get_formset(self, request, obj=None, **kwargs):
formset = super(AlbumInline, self).get_formset(request, obj, **kwargs)
formset.form.__init__ = curry(formset.form.__init__, request=request)
return formset
这行得通,但是这个解决方案是线程安全的吗?如果不是,我该如何解决?