Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#29990 closed Bug (invalid)

Error in part 7 of the tutorial

Reported by: Shrey Owned by: Shrey
Component: Documentation Version: 2.1
Severity: Normal Keywords: documentation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The code given at https://docs.djangoproject.com/en/2.1/intro/tutorial07/#customizing-your-project-s-templates is incorrect and misleading as the BASE_DIR variable points to the root of the main project directory as we can see from the code snipppet:

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# BASE_DIR  points to: ...\mysite\
# The tutorial assumes that it points to: ...\mysite\mysite

Hence the code in question should be changed to:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(os.path.join(BASE_DIR, 'basic'), 'templates')], #This line has been changed
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Change History (2)

comment:1 by Tim Graham, 5 years ago

Resolution: invalid
Status: assignedclosed

I think you made a mistake. The instructions say, "Create a templates directory in your project directory (the one that contains manage.py)". I'm not sure where the 'basic' directory in your suggestion comes from.

comment:2 by Shrey, 5 years ago

Yep. Now I see that it was a mistake made by me. And if the docs were to be updated the name mysite would be used instead of basic.

Note: See TracTickets for help on using tickets.
Back to Top