Living-with-machines / lwmdb

A django-based library for managing the Living with Machines newspapers metadata database schema
https://living-with-machines.github.io/lwmdb/
MIT License
2 stars 0 forks source link

Fix `mitchells.Entry.json` fixture #114

Closed griff-rees closed 1 year ago

griff-rees commented 1 year ago

A provided json fixture file generated by https://github.com/Living-with-machines/alto2txt2fixture/ for the mitchells.Entry model is currently invalid:

$ ./manage.py loaddata mitchells/fixtures/mitchells.Entry.json
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/models/fields/__init__.py", line
2072, in to_python
    return int(value)
           ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'publication_code\n0000079    1187\n0000079    1378\nName: pk, dtype: int64'

During handling of the above exception, another exception occurred:
42, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412,
in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458,
in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/loaddata.py", line 102, in handle
    self.loaddata(fixture_labels)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/loaddata.py", line 163, in loaddata
    self.load_label(fixture_label)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/loaddata.py", line 251, in load_label
    for obj in objects:
  File "/usr/local/lib/python3.11/site-packages/django/core/serializers/json.py", line 70,
in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/usr/local/lib/python3.11/site-packages/django/core/serializers/python.py", line 163, in Deserializer
    raise base.DeserializationError.WithData(
django.core.serializers.base.DeserializationError: Problem installing fixture '/app/mitchells/fixtures/mitchells.Entry.json': ['“publication_code\n0000079    1187\n0000079    1378\nName: pk, dtype: int64” value must be an integer.']: (mitchells.entry:pk=7) field_value was
'publication_code
0000079    1187
0000079    1378
Name: pk, dtype: int64'
griff-rees commented 1 year ago

Closing in favor of alto2txt2fixture issue #10.