无法使用Djangae重定向流量

时间:2019-02-12 21:36:59

标签: python django djangae

我正在尝试使用djangae仅提供静态文件。另外,我想将所有流量路由到index.html。当我访问http://localhost:8000时,出现500错误。当我访问http://localhost:8000/static/index.html时,我得到了正确的文件。

我在做什么错了?

我的urlpatterns如下:

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

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

我尝试过r'^$'r'^.*$''',但结果没有任何区别。

views.py

from django.shortcuts import redirect

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

500错误

  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'

1 个答案:

答案 0 :(得分:1)

我发现了在这个特定方面的解决方法。我将zone.tab文件移到了<project_name>/,并编辑了app.yaml以包含以下环境变量:PYTZ_TZDATADIR: <project_name>

仍然不确定为什么在完成路由之前需要调用pytz。