Can Not Find Django Tutorial Django-polls Templates Error

Table of Contents

1. Question.

According to the official document tutorial of Django project, i meet below problems in the chapter “Advanced tutorial: How to write reusable apps”.

  1. Install django-polls to MySite as directed.
    pip --user install /Users/john/django-polls/dist/django-polls-0.1.tar.gz
  2. Run Django server after install successfully.
    python manage.py runserver
  3. Browse url http://127.0.0.1:8000/polls/ in a web browser and returns an error.
  4.  

    Below is mysite’s setting.py file TEMPLATES section.

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'templates')],
            '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',
                ],
            },
        },
    ]

2. Answer.

  1. The reason for this error maybe wrong directory or directory does not have the corresponding template file, you can create the template file to fix it.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.