[SOLVED] Video 12-014 Djanjo Templates 'os' not defined when setting 'DIRS':

Hi,
In Section 12 on Django, you are advised to use the same version of Django Mosh is using to avoid issues. If however you use the most up to date version, you will not have any issues till you get to video 14 - Sharing a Template Across Multiple Apps.

if you get the following error in the terminal :

    "DIRS": [os],
NameError: name 'os' is not defined

This is because Django has changed how you define the ‘DIRS’: in the TEMPLATES section of settings.py

In the video @ 03:31 it shows

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [os.path.join(BASE_DIR,  'templates'],

but with the newer versions of Django now you need to use:

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [BASE_DIR / "templates"],

I found this out at django project tutorial

Finally, if you are curious how the BASE_DIR is defined, scroll to the top of settings.py where you will find:

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent