zyv / pilot_log

Simple Django pilot log webapp
MIT License
4 stars 3 forks source link

Init script fails with error #113

Closed DerK96 closed 3 months ago

DerK96 commented 3 months ago

Problem

Executing the following command from the Usage section ends in an error.

./manage.py loaddata logbook/fixtures/data/aerodromes.json

Error

Traceback (most recent call last):
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/serializers/json.py", line 70, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/serializers/python.py", line 114, in Deserializer
    Model = _get_model(d["model"])
                       ~^^^^^^^^^
KeyError: 'model'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/flippi/pilot_log/./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/commands/loaddata.py", line 102, in handle
    self.loaddata(fixture_labels)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/commands/loaddata.py", line 163, in loaddata
    self.load_label(fixture_label)
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/management/commands/loaddata.py", line 251, in load_label
    for obj in objects:
  File "/home/flippi/miniconda3/lib/python3.12/site-packages/django/core/serializers/json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/home/flippi/pilot_log/logbook/fixtures/data/aerodromes.json': 

System

zyv commented 3 months ago

Sorry, I put the wrong command in the README. The situation with aerodromes is not great at the moment...

In the very beginning I stole the data from Philips internal app by @snps-achim and cleaned it up a little bit, which is basically a list of airfields within 600 miles from Aachen.

This file is not a real Django fixture, but a cleaned dump from the Philips app, this is why a custom loading command is needed. I wrote it initially to clean up the data by cross-referencing with other sources, but then deactivated the cleanup part.

What is missing is the rest of the world, and also an update strategy. In theory one needs to think of a better source (OpenAIP, OurAirports, whatever...) considering the licensing and data quality. Also initialization and update strategy should be considered.

Fixed distance from Aachen is a bad idea as well. Probably I'd need to add local coordinates to the settings, and recalculate the ranges using the great circle distance formula. One could also do it at the database level, but one needs to register a function or limit to PostGis. Was not sure how fast this would be on the fly, so maybe indeed better to recalculated statically at the import / update stage...

Anyways, had a lot of other more pressing things to do, so this will probably stay like that for awhile.

zyv commented 3 months ago

P.S. Just to reiterate the offer made to Georg, I can give a talk / do a demo if FH pays for a demonstration flight and a dinner at Albatros ;-)