Note that there are some explanatory texts on larger screens.

plurals
  1. PONewbie Django urls, views, and templates - how can this incredibly simple django project possibly be failing?
    text
    copied!<p>When the user lands at <a href="http://127.0.0.1:8000/" rel="nofollow">http://127.0.0.1:8000/</a> I would like to display an html page that says "welcome." When the user goes <a href="http://127.0.0.1:8000/time/" rel="nofollow">http://127.0.0.1:8000/time/</a> I would like to display the current time. I have followed instructions to the t and dotted every i. My settings are below. Why do I continue to get a TemplateDoesNotExist error?</p> <pre><code>views.py from django.template.loader import get_template from django.shortcuts import render import datetime def current_datetime(request): now = datetime.datetime.now() current_datetime_template = get_template('current_datetime.html') context_dict = {'current_date': now} return render(request, current_datetime_template, context_dict) def welcome(request): welcome_template = get_template('welcome.html') context_dict = {'username' : 'Sally Jenkins'} return render(request, welcome_template, context_dict) </code></pre> <hr> <pre><code>urls.py from django.conf.urls.defaults import patterns, include, url from simpletest.views import welcome, current_datetime urlpatterns = patterns('', url(r'^time/$', current_datetime), url(r'^$', welcome), ) </code></pre> <hr> <pre><code>settings.py ... # all defaults ommitted here - I changed nothing. TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'), ) </code></pre> <p>In my django project directory I have a directory called <code>templates</code> and it contains <code>base.html</code>, <code>current_datetime.html</code>, and <code>welcome.html</code> just as expected.</p> <p>Please tell me what I have overlooked.</p> <p>Thanks.</p> <p>MORE INFO:</p> <p>I am using virtualenv. Does the fact that I have two django projects in the <code>/Users/quanda/dev/django-projects/</code> make any difference? I can't imagine it would. One is called "blossom" and is the main project I am working on. The other is called "simpletest" and I made it extremely simple so that I could isolate the issue I was having in my blossom project. I am using the same virtual environment for both projects. Running <code>tree -L 2</code> from django-projects/ gives the following structure:</p> <pre><code>. ├── Procfile ├── blossom │   ├── __init__.py │   ├── __init__.pyc │   ├── fixtures │   ├── manage.py │   ├── onora │   ├── settings.py │   ├── settings.pyc │   ├── sqlite3-database │   ├── templates │   ├── test_stuff.py │   ├── urls.py │   ├── urls.pyc │   ├── views.py │   └── views.pyc ├── requirements.txt ├── simpletest │   ├── __init__.py │   ├── __init__.pyc │   ├── manage.py │   ├── settings.py │   ├── settings.pyc │   ├── templates │   ├── urls.py │   ├── urls.pyc │   ├── views.py │   └── views.pyc └── virtual_environment ├── bin ├── django-registration-0.8-alpha-1.tar ├── include └── lib </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload