Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

AttributeError: 'Settings' object has no attribute 'TH_SERVICES' #290

Closed
jorgeas80 opened this issue Jun 4, 2018 · 5 comments
Closed

AttributeError: 'Settings' object has no attribute 'TH_SERVICES' #290

jorgeas80 opened this issue Jun 4, 2018 · 5 comments

Comments

@jorgeas80
Copy link

jorgeas80 commented Jun 4, 2018

Environment:

  • OS: Ubuntu 18.04
  • Docker version 18.03.1-ce, build 9ee9f40
  • Python 3.6.5

I followed these steps:

  1. git clone https://github.com/push-things/django-th.git
  2. cd django-th
  3. docker-compose build
  4. cp django-th/env.sample django-th/.env (no difference if I do not follow this step)
  5. docker-compose run web python manage.py migrate --settings=django_th.settings_docker

Got the error mentioned in the issue's title. This is the complete stack trace:

Starting djangoth_db_1 ... done
/usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <https://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
    app_config.ready()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
    self.module.autodiscover()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/usr/local/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/django_th/admin.py", line 5, in <module>
    from django_th.forms.services import ServicesAdminForm
  File "/app/django_th/forms/services.py", line 25, in <module>
    class ServicesAdminForm(forms.ModelForm):
  File "/app/django_th/forms/services.py", line 42, in ServicesAdminForm
    name = forms.ChoiceField(choices=available_services())
  File "/app/django_th/forms/services.py", line 17, in available_services
    for class_path in settings.TH_SERVICES:
  File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 57, in __getattr__
    val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'TH_SERVICES'

Same error if I run docker-compose up

@foxmask
Copy link
Owner

foxmask commented Jun 5, 2018

In the settings_docker.py, in place of

from .settings import *

Put This

from .th_settings import *

@foxmask
Copy link
Owner

foxmask commented Jun 5, 2018

made a try this morning with previous comment

after docker-compose build and docker-compose up

web_1    | Run 'python manage.py migrate' to apply them.
web_1    | June 05, 2018 - 09:47:57
web_1    | Django version 2.0.6, using settings 'django_th.settings_docker'
web_1    | Starting development server at https://0.0.0.0:8000/
web_1    | Quit the server with CONTROL-C.

@foxmask
Copy link
Owner

foxmask commented Jun 5, 2018

I keep the issue open to fix that later this day + changing email in dockerfile

@jorgeas80
Copy link
Author

That was easy! Thanks.

What is the other issue about changing email? Will I need to pull any fix from repo?

@foxmask
Copy link
Owner

foxmask commented Jun 5, 2018

no no issue with the email :) the previous comment is my todolist.
the domain trigger-happy.eu is dropped at EOM, so need to change the email in the dockerfile, no more or less :)

@foxmask foxmask closed this as completed in 8a7170e Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants