Saturday, February 25, 2017

"TemplateDoesNotExist at /"

"TemplateDoesNotExist at /"

(full trace log at http://dpaste.com/3XZ8H3C)

this must be near the top of django newby issues, but i'm stumped
on the simplest example i can generate:

i've used the `settings.TEMPLATES.DIRS` variable to specify a
shared templates directory (also to simplify things), and
am using an application's `views.py` file to anchor a
named url, but the django engine still cannot find the `index.html` file
i've put there.

what am i missing?  any hints appreciated,  Rik

.
├── db.sqlite3
├── djggApp
  ├── __init__.py
  ├── __init__.pyc
...
  ├── views.py
  └── views.pyc
├── djggProj
  ├── __init__.py
  ├── __init__.pyc
  ├── settings.py
  ├── settings.pyc
  ├── urls.py
  ├── urls.pyc
  ├── wsgi.py
  └── wsgi.pyc
├── manage.py
└── templates
...
   
├── index.html
* djggProj/settings.py:
 
   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',
               
],
           
},
       
},
   
]


* djggProj/urls.py

  
  from djggApp import views
   
    urlpatterns
= [
        url
(r'^$', views.index, name='index'),
   
...
        url
(r'^admin/', admin.site.urls),
   
]


* djggApp/views.py

   def index(request):
       
template = loader.get_template('index.html')
        context
= Context({})
       
return HttpResponse(template.render(context))




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9adb4f23-8382-4313-9873-aa13c30a06a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment