0

我第一次在 Django 中使用自定义模板标签。经过一番麻烦,我得到了它的工作runserver。但是现在当我尝试通过 Apache(使用 mod_wsgi)访问该页面时,我得到了错误:

TemplateSyntaxError at /
'webpage_helpers' is not a valid tag library: Template library webpage_helpers not found,
tried django.templatetags.webpage_helpers,django.contrib.admin.templatetags.webpage_helpers,django.contrib.staticfiles.templatetags.webpage_helpers,webpage.templatetags.webpage_helpers

我的文件结构如下:

project/
    project/
        wsgi.py
        settings.py 
    webpage/
        __init__.py
        views.py
        models.py
        templatetags/
            __init__.py
            webpage_helpers.py
    static/
    templates/
        base/
            base.html
        webpage/
            index.html

错误开始于webpage/index.html

{% extends 'base/base.html' %}
{% load webpage_helpers %}

wsgi.py的仍然是默认的,它只包含一条指向settings.py.

该错误表明它清楚地将正确的位置 ( webpage.templatetags.webpage_helpers) 作为最后一项。

我尝试通过以下方式重新启动apache: sudo service apache2 restart

请记住,它与runserver.

有谁知道我做错了什么?

4

1 回答 1

0

解决了。

这是一个权限问题,我的 ftp 设置不正确,并创建了权限不正确的文件和文件夹。我将项目的目录修改为 755,文件修改为 644,它现在可以工作了。

于 2015-08-06T05:41:31.970 回答