python - 如何将模板包含到 django 包中?

标签 python django

我创建了一个新的 django 应用程序并将其作为新包上传到 pypi。但是当我们将包安装到项目时,模板文件夹内的 html 文件没有显示。为什么会发生这种情况?下面还给出了 setup.py 文件(示例):

from distutils.core import setup

setup(
    name='test',
    version='0.1.0',
    author='Devs',
    author_email='tester@gmail.com',
    packages=     ['tester','tester.apps','tester.templates'],
    url='http://pypi.python.org/pypi/tester/',
    license='LICENSE.txt',
    description='A reusable app',
    long_description=open('README.txt').read(),
    install_requires=[
        "Django == 1.5",
        "Unidecode==0.04.14",
        "django-ckeditor==4.0.2",
        "django-email-extras==0.1.13",
        "django-extensions==1.2.5",
        "django-forms-builder==0.9",
        "jsonfield==0.9.20",
        "python-gnupg==0.3.5",
        "sphinx-me==0.2.1",
        "wsgiref==0.1.2",
        "South==0.8.4",
    ],
)

最佳答案

Django 模板目录不是 Python 包。您可能需要specify them as data_files in Distutils .

关于python - 如何将模板包含到 django 包中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21402709/

相关文章:

Django 管理员自定义 list_display

django - 如何在我的 Django 应用程序中使用 Dojo?

Python SQL 更新查询 : string or integer address expected instead of instance instance

javascript - 在 Django 中,如何在管理表单中显示站点缩写而不是完整的站点域?

python - 如何在 Django 中测试 auto_now_add

python - 带有 MultiIndex : check if string is contained in index level 的 Pandas 数据框

python - 如何在自定义 Django ModelChoiceField 上获取 help_text

django - Haystack 搜索结果 : how to use different templates for different models in page. object_list?

python - TypeError at/accounts/register/__init__() 得到意外的关键字参数 'instance'

python - docker swarm 抛出错误 "swarm already part of swarm"