civictechindex / CTI-website-backend

Python-Django based backend for Civic Tech Index

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BACKEND][BUG] Geeting Error while tryign to use `django-admin dumpdata` in `cti-website-backend_web_1` container

emecas opened this issue · comments

Error Message

# django-admin dumpdata faqs
Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 8, in <module>
    sys.exit(execute_from_command_line())
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 368, in execute
    self.check()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
    all_issues = checks.run_checks(
  File "/usr/local/lib/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/usr/local/lib/python3.8/site-packages/django/core/checks/security/base.py", line 236, in check_default_hashing_algorithm
    if settings.DEFAULT_HASHING_ALGORITHM not in {'sha1', 'sha256'}:
  File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_HASHING_ALGORITHM, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
#

Fix:

Export environment variable pointing to settings file. It seems that for cti-website-backend_web container configuration is located in /CTI-website-backend/config/settings.py file

Ref: https://stackoverflow.com/questions/47700347/django-core-exceptions-improperlyconfigured-requested-setting-use-i18n-but-set#47700674

@emecas Please use the manage command to dump data. It explicitly references the settings.

python manage.py dumpdata --indent 4 data.faq