I have an issue when i want import data from an dataset with django import export user model ressource :
error :
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
My ressource :
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',)
My model :
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)
My code:
I use an existing file for implemented my dataset depending to confitions, et i want to test dataset integration using ressource of my model
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)
thank you in advance
It was an error around my resources... I had forgotten to initialize my resources:
dossier_ressource = MasterdossierRessource()
result = dossier_ressource.import_data(dataset, dry_run=True, raise_errors=True)