In the process of deploying the created Django app to AWS EC2 (Ubuntu16.04), I encountered the following error, so I will write down the remedy.
After git clone
the Django project in Ubuntu, I ran python3 manage.py make migrations
TypeError: resolve() got an unexpected keyword argument 'strict'
Error was displayed.
settings.py
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
It seems that one sentence of is an error. This is the description to get the absolute path of the base directory where Django manage.py is located.
I wondered why this was because I don't remember messing around with it, and found that the description of this part changed between Django 3.1 and later and before that.
This time I was developing locally with Python 3.8 + Django 3.1, but when I confirmed it, Python 3.5 + Django 2.2 is installed on Ubuntu, and it seems that there is an error due to the difference in version.
The strict argument of the resolve method seems to have been added since python3.6, so this is probably the root cause.
Originally, it was necessary to develop according to the version of Django in Ubuntu, but this time I just wanted to easily try to deploy it, so I will change settings.py to the description according to Django 2.2.
settings.py
#This is Django 3.1 or later
# from pathlib import Path
# BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
#Traditional description
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
By doing this, the error was successfully resolved and the migration was successful.
I think language and framework version control is especially important in development, so I'd like to be careful in the future.
Recommended Posts