请收到此错误不知道为什么“无法将‘设置’对象隐含STR”

问题描述 投票:1回答:1
@admin.register(Book)
class BookAdmin(ImportExportActionModelAdmin):
   resource_class = BookResource

   def get_import_form(self):
       return CustomImportForm

   def get_resource_kwargs(self, request, *args, **kwargs):
       rk = super().get_resource_kwargs(request, *args, **kwargs)

       rk['input_author'] = None

       if request.POST:
           author = request.POST.get('input_author', None)
           if author:
               request.session['input_author'] = author
           else:
               try:
                   author = request.session['input_author']
               except KeyError as e:
                   raise Exception("Context failure on row import" + {e})

           rk['input_author'] = author
       return rk

在Django管理页面的代码,但出口过程中得到一个错误。任何人都可以让我知道在哪里的问题?

enter image description here

python django django-sessions
1个回答
1
投票

你的问题是在这条线:

raise Exception("Context failure on row import" + {e})

在“{E}”意味着你创建一个包含该错误的设定,并尝试将其加入到异常消息字符串。您应该能够通过只用“E”取代“{E}”摆脱错误的。

© www.soinside.com 2019 - 2024. All rights reserved.