软件:
Python3.6.2 Django1.11
django
-import-export==0.5.1
OSX10.12.6
安装_应用程序:
THIRD_PARTY_APPS = [
...,
'reversion', # django-reversion
'import_export', # django-import-export
]
要求:
1. 模型有reversion
2. 模型可以做import
3. 每个导入的角色都有上传者为created_user
, 和updated_user
(但是,现在我让它从 Excel 文件中读取,这就是问题所在)
尝试:
1.由于要求中的2个将受到严格的meta
班级的严厉打击。然后我应用reichert
解决方案https://github.com/etianen/django-reversion/issues/323
2。
问题:
Line number: 1 - get() keywords must be strings
None, 696 02, Lane, Ronald Regan, Ratíškovice, n/a, Dolichitus patagonum, admin, admin
Traceback (most recent call last):
File "/Users/el/.pyenv/versions/soken/lib/python3.6/site-packages/import_export/resources.py", line 434, in import_row
instance, new = self.get_or_init_instance(instance_loader, row)
File "/Users/el/.pyenv/versions/soken/lib/python3.6/site-packages/import_export/resources.py", line 258, in get_or_init_instance
instance = self.get_instance(instance_loader, row)
File "/Users/el/.pyenv/versions/soken/lib/python3.6/site-packages/import_export/resources.py", line 252, in get_instance
return instance_loader.get_instance(row)
File "/Users/el/.pyenv/versions/soken/lib/python3.6/site-packages/import_export/instance_loaders.py", line 33, in get_instance
return self.get_queryset().get(**params)
TypeError: get() keywords must be strings
问:
接下来我该怎么办?
型号:
https ://gist.github.com/elcolie/98e641d57c5de3394f816a5d9b80ef13
admin.py
https://gist.github.com/elcolie/081017adc7b5e2fd7a3a38b0573597c6
参考资料:
处理 django-import-export 中的 foreignKeys 导入
django-import-export 导出用户模型
Django Import/Export to multiple Models (foreignkey)