Search code examples
pythondjangodjangae

Unable to redirect traffic using Djangae


I am attempting to use djangae to serve static files only. In addition, I want to route all traffic to an index.html. When I visit http://localhost:8000 I get a 500 error. When I visit http://localhost:8000/static/index.html, I get the correct file.

What am I doing wrong?

My urlpatterns are as follows:

...
from . import views
...
urlpatterns = (
    ...

    url(r'^', views.home),
)

I have tried r'^$', r'^.*$', and '', but I do not get any difference in the outcome.

views.py:

from django.shortcuts import redirect

def home(request):
    return redirect('/static/index.html', permanent=True)

500 Error

  File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 493, in <module>
    for l in open(os.path.join(_tzinfo_dir, 'zone.tab'))
  File "/git_repos/djangae/proj/sitepackages/dev/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 260, in __init__
    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/usr/share/zoneinfo/zone.tab'

Solution

  • I have discovered a work around in this particular aspect. I moved the zone.tab file to <project_name>/ and edited my app.yaml to include this environment variable: PYTZ_TZDATADIR: <project_name>.

    Still unsure why pytz needs to be called before a route is completed.