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

Correct loading of `gazetteer` fixtures #112

Closed griff-rees closed 1 year ago

griff-rees commented 1 year ago

Loading json fixtures produced by https://github.com/Living-with-machines/alto2txt2fixture requires a correct ordering. Thus far, making created_at and modified_at optional is required. Once modified:

json provided for gazetteer works in the following order:

But fails loading gazetteer.Place.json:

  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/gazetteer/fixtures/gazetteer.Place.json': ['“” value must be an integer.']: (gazetteer.place:pk=1) field_value was ''

The fixture file does include pk fields though (first entry for example):

[{"pk": 1, "model": "gazetteer.place", "fields": {"wikidata_id": "Q1000115", "label": "Faversham", "latitude": 51.3177, "longitude": 0.8928, "geonames_ids": "['2649    622', '7297621']", "historic_county": 1.0, "admin_county": "", "country": 1.0}}]
griff-rees commented 1 year ago

See https://github.com/Living-with-machines/alto2txt2fixture/issues/9