1
Django is supporting pathlib starting from verson 3.1.
Make sure you are using supported Django version and your settings file has:
from pathlib import Path
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
Source:stackexchange.com