Path Settings Change in Django 3.1
From Django 3.1, the Django
setting.py file replaces the
os module from Python with
from pathlib import Path
For existing projects, this will not affect the operation of your code. If you start a new project with Django 3.1, however, the code in my books, courses and website will break on the
You have two options to resolve this problem. The simplest is to add
import os to your Django 3.1 settings file.
The second option is to change your settings to use
pathlib. This is the best option, as Django will use pathlib from 3.1 onwards, so you might as well get used to the change.
You need to make two changes.
'DIRS': [os.path.join(BASE_DIR, 'myclub_site/templates')],
in your TEMPLATES setting to:
'DIRS': [BASE_DIR / 'myclub_site/templates'],
STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'myclub_site/static'), ]
STATICFILES_DIRS = [BASE_DIR / 'myclub_site/static')]