2020-12-10 collecstatic error

bima at x220 in /m/F/A/W/P/gealtikdemo
(env) ↪ python3 manage.py collecstatic
Traceback (most recent call last):
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 224, in fetch_command
    app_name = commands[subcommand]
KeyError: 'collecstatic'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 231, in fetch_command
    settings.INSTALLED_APPS
  File "/home/bima/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 83, in __getattr__
    self._setup(name)
  File "/home/bima/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 70, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/bima/.local/lib/python3.6/site-packages/django/conf/__init__.py", line 177, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/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 "/mnt/F0CAA068CAA02D32/Assets/Workspace/Project_portfgealtik/gealtikdemo/personal_portfolio/settings.py", line 14, in <module>
    import django_heroku
ModuleNotFoundError: No module named 'django_heroku'
bima at x220 in /m/F/A/W/P/gealtikdemo
(env) ↪ pip3 install django-heroku
Collecting django-heroku
  Using cached https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
Collecting whitenoise (from django-heroku)
  Using cached https://files.pythonhosted.org/packages/50/83/5d91949e370e52578a99ef6391c3b3e19f9fd1f5b4f58d5cbd6e2862d4a8/whitenoise-5.2.0-py2.py3-none-any.whl
Collecting psycopg2 (from django-heroku)
  Using cached https://files.pythonhosted.org/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vk_7wt4v/psycopg2/

Pesan error yang berawal dari gagalnya instalasi django-heroku

Tampilan tersebut tidak jauh beda dengan yang ada di build heroku dengan yang ada di lokal. Maka error tersebut tidak jauh-jauh dengan masalah modul

pertama

Use these following commands, this will solve the error:

sudo apt-get install postgresql

then fire:

sudo apt-get install python-psycopg2

and last:

sudo apt-get install libpq-dev

Selanjutnya

di virtualenv

pip3 install django-heroku
pip3 install psycopg2

dan sekarang errornya lebih spesifik persis dengan tampilan di build pipeline saat menjalankan python3 manage.py collecstatic --noinput

    config['STATIC_ROOT'] = os.path.join(config['BASE_DIR'], 'staticfiles')
KeyError: 'BASE_DIR'

untuk itu kita telusuri di settings.py pasti ada typo based on hint error kita suruh liat ginian https://devcenter.heroku.com/articles/django-assets

pip3 install whitenoise

dan juga tambah di requirements

sementara disable line ini dulu

django_heroku.settings(locals())

Last updated

Was this helpful?