3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Django debug=false で error 500と出て デプロイできない時

Last updated at Posted at 2020-07-04

先ほどこのエラーでかなり沼ったのでまとめ

settings.py

debug = True

で問題なく動くのに

debug = falseの時

$ python manage.py collectstatic

コマンドを打っても

server error(500)が出た方はみてみてください

本題

settings.py

debug = false

に変え、デプロイの工程が終了かと思いきや

server error(500)

ため息混じりで、仕方なくググっていると

$ python manage.py collectstatic
コマンド打ても変わらず

唯一のエラーは
$ cat /var/log/apache2/error.log

Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=False debug=False>>
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/base_events.py", line 526, in __del__
NameError: name 'ResourceWarning' is not defined

だけ、その場合は

settings.py

debug = True

------------------

# STATIC_URL = '/static/'

# STATIC_ROOT = os.path.join(BASE_DIR, 'static')

とやってエラーが出たhtnmlの行を消してみると動いたりします。
勿論、そのせいでstatic cssは適応されませんが。

今回の問題は指定したtemplatesにcss staticが反映されていないからなので、一度ローカルでstaticのエラーを直してから再度デプロイするのがいいかもしれません。

html templateのエラーを取り除いたあとはstaticの記載のコメントアウトを外すのは忘れずに。(adminが動かなくなる)

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?