我正在 admin.py 中进行导入导出到 excel,每次单击导入按钮时,我都会收到此错误“CustomerPurchaseOrder”对象没有属性“get_user_visible_fields”我不知道我的代码出了什么问题,我一直在遵循文档(以下)。我的代码中遗漏了什么吗?class CustomerPurchaseOrderResource(resources.ModelResource): class Meta: model = CustomerPurchaseOrder fields = ('profile', 'customer_Purchase_Order_Detail', 'process', 'deliverySchedule', 'deliveryDate', 'paymentmethod', 'requestedDate',)class CustomerPurchaseOrderAdmin(ImportExportModelAdmin): list_filter = ("process", "deliverySchedule", "inputdate") list_display = ( 'profile', 'customer_Purchase_Order_Detail', 'process', 'deliverySchedule', 'deliveryDate', 'paymentmethod', 'requestedDate',) ordering = ('id','requestedDate') resource_class = CustomerPurchaseOrder这是我的 models.pyclass CustomerPurchaseOrder(models.Model): profile = models.ForeignKey(Customer, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Client Account") customerdeliveryaddress = models.ForeignKey(CustomerDeliveryAddress, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Delivery Address") customer_Purchase_Order_Detail = models.ForeignKey('CustomerPurchaseOrderDetail', on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Customer Purchase Order") process = models.ForeignKey('Process', on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Process")
1 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
您需要resource_class
在您的CustomerPurchaseOrderAdmin
to中进行设置CustomerPurchaseOrderResource
,而不是CustomerPurchaseOrder
按照链接的文档进行设置。
添加回答
举报
0/150
提交
取消