0
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 1 year has passed since last update.

Djangoスタートアップ(サーバーエラー(500)編)

Last updated at Posted at 2023-04-27

Sever error 500の対処方法

エラー内容

models.pytemplateファイルを編集して本番環境にデプロイしたらServer error 500が表示されてしまう。

仕様技術

  • サーバー
    • AWS
      • EC2(ubuntu)
        • Postgresql
        • gunicorn
        • nginx
      • ROUTE53

試したこと

管理者サイトにはアクセスできるが、管理者サイトのデータベースに関するページにアクセスするとServer error 500が表示される

  1. nginx, gunicorn, postgresqlの再起動
    →治らず

  2. Djangoプロジェクトディレクトリ/アプリケーションディレクトリ/migrations/init.py以外の削除
    python manage.py makemigrations & python manage.py migratePostgresqlのテーブルと整合性が取れない旨のエラー

  3. Postgresqlのテーブルごと削除&python manage.py makemigrations & python manage.py migrateを実行
    →DBが新たに作成されてSever error 500が消えた

今後の対策

開発環境のmigrationsディレクトリと本番環境のmigrationsディレクトリは非同期にして、models.pyのみ同期させる。migrationは各サーバーで行う。

0
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
0
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?