Re: Not reading from TEMPLATE_DIRS in settings.py

888 views
Skip to first unread message

ephan

unread,
Aug 14, 2012, 9:54:45 AM8/14/12
to Django users
Have you checked the permissions of the directory and template
files?
run ls -l in the parent directory of the template folder and inside
the folder itself .
madala wrote:
> Have followed tutorial 2 instructions carefully. So far everything has
> worked as described in tutorials but cannot get django to load files from
> my own template directory. Seems a very simple problem.
>
> here's the part of my settings.py:
>
> TEMPLATE_DIRS = (
> '/home/madala/WebsiteCode/templates',
> "/home/madala/Website/templates",
> # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
>
> So I carried on and started tutorial 3 till I got halfway down and had to
> do same thing but no matter what I try can't get Django to recognize my
> directories.
>
> Can anyone see where I am going wrong please? thanks in anticipation.

Alexis Roda

unread,
Aug 14, 2012, 9:59:11 AM8/14/12
to django...@googlegroups.com
Al 14/08/12 12:50, En/na madala ha escrit:
>
> So I carried on and started tutorial 3 till I got halfway down and had
> to do same thing but no matter what I try can't get Django to recognize
> my directories.
>
> Can anyone see where I am going wrong please? thanks in anticipation.

What error are you getting? template not found? please pastebin the
traceback.



Regards

madala

unread,
Aug 17, 2012, 5:15:36 AM8/17/12
to django...@googlegroups.com
Yes I can access the directories. Here's the traceback:
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 153, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
    return callback(request, **param_dict)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/defaults.py", line 32, in server_error
    t = loader.get_template(template_name) # You need to create a 500.html template.
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 145, in get_template
    template, origin = find_template(template_name)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 138, in find_template
    raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html
[17/Aug/2012 10:11:59] "GET / HTTP/1.1" 500 59

madala

unread,
Aug 17, 2012, 5:16:48 AM8/17/12
to django...@googlegroups.com
Thanks you for replying. Here is traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 153, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
    return callback(request, **param_dict)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/defaults.py", line 32, in server_error
    t = loader.get_template(template_name) # You need to create a 500.html template.
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 145, in get_template
    template, origin = find_template(template_name)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 138, in find_template
    raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html
[17/Aug/2012 10:11:59] "GET / HTTP/1.1" 500 59


Amyth Arora

unread,
Aug 17, 2012, 5:21:22 AM8/17/12
to django...@googlegroups.com
While you get this error do you see your template dir listed on the
error/debug page ?
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/fif5nO4VPsYJ.
>
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



--
Thanks & Regards
----------------------------

Amyth [Admin - Techstricks]
Email - aroras....@gmail.com, ad...@techstricks.com
Twitter - @a_myth_________
http://techstricks.com/

madala

unread,
Aug 17, 2012, 8:46:53 AM8/17/12
to django...@googlegroups.com
Thanks I solved it. Was looking up wrong directory because I followed the instructions to put the absolute path. If I put the relative path it works fine. Thanks for taking time to answer anyway. People are so kind! :0)

madala

unread,
Aug 17, 2012, 8:47:14 AM8/17/12
to django...@googlegroups.com
Thanks I solved it. Was looking up wrong directory because I followed the instructions to put the absolute path. If I put the relative path it works fine. Thanks for taking time to answer anyway. People are so kind! :0)

On Tuesday, 14 August 2012 14:59:11 UTC+1, Alexis Roda wrote:

madala

unread,
Aug 17, 2012, 8:47:29 AM8/17/12
to django...@googlegroups.com
Thanks I solved it. Was looking up wrong directory because I followed the instructions to put the absolute path. If I put the relative path it works fine. Thanks for taking time to answer anyway. People are so kind! :0)

On Tuesday, 14 August 2012 14:54:45 UTC+1, ephan wrote:

Amyth Arora

unread,
Aug 17, 2012, 12:31:34 PM8/17/12
to django...@googlegroups.com
Glad that you solved it! However, i would recommend using absolute
path instead of a relative path as it might break when you clone or
move it to another location.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/-WksJy4qUkoJ.

Melvyn Sopacua

unread,
Aug 18, 2012, 10:16:07 AM8/18/12
to django...@googlegroups.com
On 17-8-2012 14:47, madala wrote:
> Thanks I solved it. Was looking up wrong directory because I followed the
> instructions to put the absolute path. If I put the relative path it works
> fine. Thanks for taking time to answer anyway. People are so kind! :0)

You didn't solve it because it /should/ be absolute paths. Can you try
the following:
cd <your project dir>
python manage.py shell

At the prompt:
>>> from django.conf import settings
>>> import os.path
>>> [ os.path.abspath(d) for d in settings.TEMPLATE_DIRS ]

That should show you the absolute paths django has now come up with.
Compare them with your originals:
'/home/madala/WebsiteCode/templates',
"/home/madala/Website/templates",

--
Melvyn Sopacua
Reply all
Reply to author
Forward
0 new messages