CSV上载前未设置任何格式 [英] CSV upload with no set format before upload

查看:42
本文介绍了CSV上载前未设置任何格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Django适配器,但是效果很好,开始看到CSV上传,用户可以在上传后以无设置格式决定上传后数据所属的列.

I'm using Django adaptors it works very well however, I'm starting to see CSV uploads where the user can decide what column the data belongs to after upload with no set format before upload.

是否可以将其构建到Django Adaptors中,如果可以的话,是否可以使我朝正确的方向发展?

有没有可以执行此操作的应用程序?(我已经搜索过,没有任何乐趣)

Is there any app out there that could do this? (I have searched, with no joy)

推荐答案

您需要从CSVModel类继承,并扩展/覆盖get_fields方法(如果需要,还可以使用其他方法).这是动态构建声明性类实例的常见模式.

You need to inherit from CSVModel class and extend/overwrite get_fields method (and other methods if needed). This is common pattern for dynamic building instances of declarative classes.

看看此代码

ProductForm类,这不完全是您的情况,但重点是相同的.

ProductForm class, this is not exactly your case, but the point is the same.

这篇关于CSV上载前未设置任何格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆