4

I would like to print this value for debugging purposes. How can I do it?

print TEMPLATE_DIRS doesn't work print settings.TEMPLATE_DIRS doesn't work.

Deonomo
  • 1,583
  • 3
  • 16
  • 25

2 Answers2

4

Did you import the settings first?

$steve ./manage.py shell

Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)

In [1]: from django.conf import settings
In [2]: settings.TEMPLATES[0]['DIRS']
Out [2] ('/Volumes/HDD/usr/local/django/mytestproject/templates',)
Steve Jalim
  • 11,989
  • 1
  • 37
  • 54
  • Also, since you seem knowledgeable -- any chance you could glance at this question: http://stackoverflow.com/questions/8885107/newbie-django-urls-views-and-templates-how-can-this-incredibly-simple-django ? – Deonomo Jan 16 '12 at 20:13
  • 1
    `TEMPLATE_DIRS` has since been renamed to `TEMPLATES` if you are using a more modern version – run_the_race Jul 01 '22 at 15:02
1

I think the easiest, and therefore the ans you may be looking for is to add the following to your settings.py

print ("This is the template.dirs", TEMPLATES[0]['DIRS'])...python 3.x for 2.x leave out the parentheses

so the answer is... standard way to access dict element within a list TEMPLATES[0]['DIRS']

Then when you run your server the values will be printed out, at the very beginning

Paddy Popeye
  • 1,634
  • 1
  • 16
  • 29