LoginSignup
0
0

More than 1 year has passed since last update.

Djangoでデータベース構築時のエラー解消法(Python3.8)

Posted at

はじめに

Python3.8でDjangoのデータベースを構築した際にPython3.8の仕様変更でエラーになった箇所の
解消法をまとめた

環境

下記の各種バージョンで実施

$ python3 --version
Python 3.8.9

$ python3 -m django --version
4.0.5

エラー1

ひとまず、マイグレーションを実行

python3 manage.py makemigrations

...(略)
'NAME': BASE_DIR / 'db.sqlite3',
TypeError: unsupported operand type(s) for /: 'str' and 'str'

'NAME'のvalue値の書き方でエラー発生

setting.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


下記へ変更

setting.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR + 'db.sqlite3',
    }
}

もう一度実行します

python3 manage.py makemigrations

Migrations for 'sample':
...(略)

エラー解消し、正常終了しました

追加があれば都度更新していきます

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