Cannot use field type twice
Trying to import two phone numbers, one into phone_number
and one into mobile
, fails, because the field type is used as column name when calling Pandas.
Exception:
[2022-01-01 22:58:31,711: ERROR/ForkPoolWorker-1] Task aleksis.apps.csv_import.util.process.import_csv[60fb9044-10d7-4d5d-a0c3-fde4fd6df2eb] raised unexpected: IntegrityError('duplicate key value violates unique constraint "django_celery_results_taskresult_task_id_key"\nDETAIL: Key (task_id)=(60fb9044-10d7-4d5d-a0c3-fde4fd6df2eb) already exists.\n')
Traceback (most recent call last):
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/celery/app/trace.py", line 409, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/celery/app/trace.py", line 701, in __protected_call__
return self.run(*args, **kwargs)
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/aleksis/core/util/celery_progress.py", line 158, in _inject_recorder
return orig(*args, **kwargs, recorder=recorder)
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/aleksis/apps/csv_import/util/process.py", line 62, in import_csv
data = pandas.read_csv(
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 586, in read_csv
return _read(filepath_or_buffer, kwds)
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 479, in _read
_validate_names(kwds.get("names", None))
File "/home/nik/AlekSIS/AlekSIS/apps/official/AlekSIS-App-CSVImport/.venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 460, in _validate_names
raise ValueError("Duplicate names are not allowed.")
ValueError: Duplicate names are not allowed.
Template snippet:
- field_type: phone_number
db_field: mobile
- phone_number
The db_field
should be overridable for all field types. Probably, args should simply be loaded verbatim and set on the class (using setattr) verbatim.
Edited by Nik | Klampfradler