点action时显示未选择action,请问有遇到的吗

作者:hoobyy 1241 浏览 18 评论 发布时间:2019-11-19 16:16:29

点action时显示:no action selected,请问有遇到的吗? setting中去掉注释掉simpleui又能正常点击action出结果.

Loading...
评论列表 18条评论
雨花
2021-08-07 11:22:08

用了simplepro 导出不正常了啊 .....

hoobyy
2020-05-04 18:14:45

@simplepro @sinching 谢谢,我将simpleui降版本从3.4到2.6就正常了(django版本是2.1.4).期望老大能在新版本中修复这个问题.

sinching
2020-05-04 18:14:45

@hoobyy def export_to_csv(self, request, queryset): #导出CSV功能 meta = self.model._meta ListName = ['序号','发起日期', '发起人员'] field_names = [field.name for field in meta.fields] response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = f'attachment; filename={meta}.csv' response.charset = 'utf-8-sig' writer = csv.writer(response) writer.writerow(ListName) for obj in queryset: row = writer.writerow([getattr(obj, field) for field in field_names]) return response 我这个没有问题,可以导出,但是很low

sinching
2020-05-04 18:14:45

@hoobyy 我是直接导出CSV 函数写得有点Low

hoobyy
2020-05-04 18:14:45

@simplepro 我也在qq群里面蹲着,要不帮我远程看看.老大.

hoobyy
2020-05-04 18:14:45

@simplepro

@admin.register(InsureInfo) class InsureInfoAdmin(admin.ModelAdmin): list_display = ('policyid','startdate','enddate','insurename','sharename','sharedate','totalpremium','sharepremium','shareportion',) list_filter = ('policyid','insurename','startdate','enddate','sharedate',)

def export(self, request, queryset):
    column_names = ['policyid','startdate','enddate','insurename','sharename','sharedate','totalpremium','sharepremium','shareportion',]
    #return de.make_response_from_query_sets(queryset,column_names,file_type='xls',file_name="导出")
    print(column_names)

def printer(self, request, queryset):
    pass

export.short_description = "导出"
printer.short_description = "打印"
actions = ['export','printer',]
社区小助手
2020-05-04 18:14:45

@hoobyy 完整的代码以文字的形式贴一下,我后续调试下。

hoobyy
2020-05-04 18:14:45

@simplepro 改成self也是同样的问题.在默认的admin界面就能正常执行action,当套上simpleui再执行时还是会提示no action selected.

社区小助手
2020-05-04 18:14:45

@hoobyy

社区小助手
2020-05-04 18:14:45

这样再试试看

def export(self,request,queryset):
.....