import_data() 缺少 1 个必需的位置参数:'dataset' -
import_data() missing 1 required positional argument: 'dataset' -
当我想使用 django import export user model ressource 从数据集中导入数据时遇到问题:
错误:
import_data() missing 1 required positional argument: 'dataset'
Request Method: GET
Request URL: http://localhost:8000/home/
Django Version: 1.11.6
Exception Type: TypeError
Exception Value:
import_data() missing 1 required positional argument: 'dataset'
Exception Location: /code/data_integration/tasks.py in MvmtjsHms, line 197
Python Executable: /usr/local/bin/python3
Python Version: 3.4.2
我的资源:
class MasterDossierResource(resources.ModelResource):
class Meta:
model = MasterDossier
skip_unchanged = True
report_skipped = False
import_id_fields = ('indice',)
exclude = ('id',)
fields = ('indice', 'plt', 'ref_dossier',)
我的模型:
class MasterDossier(models.Model):
indice = models.CharField(max_length=40, primary_key=True)
plt = models.CharField(max_length=3)
ref_dossier = models.CharField(max_length=20)
我的代码:
我根据条件使用现有文件来实现我的数据集,我想使用我的模型的资源来测试数据集集成
def Mvmtjs(self,file, espace):
import csv
csvfile = open(file, 'r')
reader = csv.reader(csvfile,delimiter=';')
dataset = tablib.Dataset(headers=['indice', 'plt', 'ref_dossier_ath'])
]
with open('tmp/edi/in/working/write_file.csv', "w+", encoding='mac_roman', newline='') as csv_file1:
next(reader) # Skip header row.
next(reader) # Skip header row.
for row in reader:
if row[2] != "":
if espace == '1' or '2':
dataset.append( (
row[2],
row[0],
row[2],
))
result = MasterDossierResource.import_data(dataset, dry_run=True, raise_errors=True)
提前致谢
我的资源出错了...我忘了初始化我的资源:
dossier_ressource = MasterdossierRessource()
result = dossier_ressource.import_data(dataset, dry_run=True, raise_errors=True)
当我想使用 django import export user model ressource 从数据集中导入数据时遇到问题:
错误:
import_data() missing 1 required positional argument: 'dataset'
Request Method: GET
Request URL: http://localhost:8000/home/
Django Version: 1.11.6
Exception Type: TypeError
Exception Value:
import_data() missing 1 required positional argument: 'dataset'
Exception Location: /code/data_integration/tasks.py in MvmtjsHms, line 197
Python Executable: /usr/local/bin/python3
Python Version: 3.4.2
我的资源:
class MasterDossierResource(resources.ModelResource):
class Meta:
model = MasterDossier
skip_unchanged = True
report_skipped = False
import_id_fields = ('indice',)
exclude = ('id',)
fields = ('indice', 'plt', 'ref_dossier',)
我的模型:
class MasterDossier(models.Model):
indice = models.CharField(max_length=40, primary_key=True)
plt = models.CharField(max_length=3)
ref_dossier = models.CharField(max_length=20)
我的代码:
我根据条件使用现有文件来实现我的数据集,我想使用我的模型的资源来测试数据集集成
def Mvmtjs(self,file, espace):
import csv
csvfile = open(file, 'r')
reader = csv.reader(csvfile,delimiter=';')
dataset = tablib.Dataset(headers=['indice', 'plt', 'ref_dossier_ath'])
]
with open('tmp/edi/in/working/write_file.csv', "w+", encoding='mac_roman', newline='') as csv_file1:
next(reader) # Skip header row.
next(reader) # Skip header row.
for row in reader:
if row[2] != "":
if espace == '1' or '2':
dataset.append( (
row[2],
row[0],
row[2],
))
result = MasterDossierResource.import_data(dataset, dry_run=True, raise_errors=True)
提前致谢
我的资源出错了...我忘了初始化我的资源:
dossier_ressource = MasterdossierRessource()
result = dossier_ressource.import_data(dataset, dry_run=True, raise_errors=True)