GeotrekCE / Geotrek-admin

Paths management for National Parks and Tourism organizations
https://geotrek.fr
BSD 2-Clause "Simplified" License
136 stars 76 forks source link

Error message when French language is missing #3897

Open geobrun opened 10 months ago

geobrun commented 10 months ago

During Geotrek-admin installation, if I don't mention French in the available languages, I get the following error:

Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Update objects translation after migration from .po files
Lang : en
TargetPortal
Label is park centered
Lang : zh-hant
TargetPortal
Label is park centered
Done.
Copy static files
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Insert initial data
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Traceback (most recent call last):
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/db/models/options.py", line 608, in get_field
    return self.fields_map[field_name]
KeyError: 'label_fr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/serializers/json.py", line 70, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/serializers/python.py", line 119, in Deserializer
    field = Model._meta.get_field(field_name)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/db/models/options.py", line 610, in get_field
    raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: Theme has no field named 'label_fr'

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

Traceback (most recent call last):
  File "/usr/sbin/geotrek", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/modeltranslation/management/commands/loaddata.py", line 49, in handle
    return super().handle(*fixture_labels, **options)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 78, in handle
    self.loaddata(fixture_labels)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 123, in loaddata
    self.load_label(fixture_label)
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 181, in load_label
    for obj in objects:
  File "/opt/geotrek-admin/lib/python3.8/site-packages/django/core/serializers/json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/opt/geotrek-admin/lib/python3.8/site-packages/geotrek/common/fixtures/
basic.json': 
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Read env configuration from /opt/geotrek-admin/lib/python3.8/site-packages/geotrek/settings/env_prod.py
Read custom configuration from /opt/geotrek-admin/var/conf/custom.py
Reload

This error doesn't seem to be critical because Geotrek-admin seems to run well anyway. But I prefer to report this error in case there is something important to fix.

camillemonchicourt commented 10 months ago

Je ne sais pas si cette erreur est problématique. Mais j'ai en souvenir (sans pouvoir en retrouver la trace) qu'on peut ajouter des langues, mais qu'actuellement on ne peut pas enlever les langues FR et EN de base.

marcantoinedupre commented 10 months ago

Cette erreur semble liée au chargement du référentiel par défaut (les thèmes par défaut, les étiquettes, etc). En effet les fichiers fixtures correspondants incluent des valeurs pour le français et l'anglais (par exemple ici geotrek/common/fixtures/basic.json) et Django ne semble pas gérer les cas où des champs indiqués dans la fixture n'existent pas dans le modèle.

Cette erreur n'est donc pas grave dans le sens où il s'agit seulement des objets du référentiel par défaut qui n'ont pas pu être créés, en totalité ou en partie.

geobrun commented 10 months ago

Ok, merci pour les précisions ! :)

Je vous laisse fermer le ticket si cela n'a pas réellement besoin d'être corrigé.

submarcos commented 10 months ago

Je pense que pour être clean, il faut soit faire en sorte que çà ne déclenche pas d'erreur, soit ne pas laisser la possibilité à l'utilisateur de déselectionner des langues requises au bon fonctionnement