2015-06-22 67 views
0

我得到錯誤「未找到模板」,雖然我已經設置了正確的模板層次(或因此我認爲)Django的模板在主項目目錄錯誤未找到

. 
├── manage.py 
├── twinja 
│   ├── admin.py 
│   ├── admin.pyc 
│   ├── __init__.py 
│   ├── __init__.pyc 
│   ├── migrations 
│   │   ├── __init__.py 
│   │   └── __init__.pyc 
│   ├── models.py 
│   ├── models.pyc 
│   ├── tests.py 
│   └── views.py 
└── twinjasite 
    ├── __init__.py 
    ├── __init__.pyc 
    ├── settings.py 
    ├── settings.py~ 
    ├── settings.pyc 
    ├── static 
    │   └── twinja 
    │    ├── fonts 
    │    │   └── bootstrap 
    │    │    ├── glyphicons-halflings-regular.eot 
    │    │    ├── glyphicons-halflings-regular.svg 
    │    │    ├── glyphicons-halflings-regular.ttf 
    │    │    ├── glyphicons-halflings-regular.woff 
    │    │    └── glyphicons-halflings-regular.woff2 
    │    ├── images 
    │    ├── javascripts 
    │    │   ├── bootstrap 
    │    │   │   ├── affix.js 
    │    │   │   ├── alert.js 
    │    │   │   ├── button.js 
    │    │   │   ├── carousel.js 
    │    │   │   ├── collapse.js 
    │    │   │   ├── dropdown.js 
    │    │   │   ├── modal.js 
    │    │   │   ├── popover.js 
    │    │   │   ├── scrollspy.js 
    │    │   │   ├── tab.js 
    │    │   │   ├── tooltip.js 
    │    │   │   └── transition.js 
    │    │   ├── bootstrap.js 
    │    │   ├── bootstrap.min.js 
    │    │   └── bootstrap-sprockets.js 
    │    └── stylesheets 
    │     ├── framework.css 
    │     └── styles.css 
    ├── templates 
    │   └── twinja 
    │    ├── base.html 
    │    └── menu.html 
    ├── urls.py 
    ├── urls.py~ 
    ├── urls.pyc 
    ├── views.py 
    ├── views.py~ 
    ├── views.pyc 
    ├── wsgi.py 
    └── wsgi.pyc 

起初我設置up templates/base但這沒有奏效。所以我做到了,因爲你在這裏看到:templates/twinja/base

理想情況下,我設置了獨立於應用程序的主要模板文件,我認爲它應該放在主文件夾中(其中settings.py是),但也許我錯了。

是的,我在'已安裝的應用程序中設置'twinja'。

這裏出現什麼問題?

TemplateDoesNotExist at/
twinja/base.html 

回答

1

如果你的模板是獨立的應用程序,它不應該在你的應用程序文件夾 - 命名空間會相應。

如何加載模板?您是否在settings.py中設置了templates/static文件夾?

更新

對於新鮮的項目,您需要配置您的settings.py文件。請閱讀here,問問你是否還有問題。

更新

在熟悉靜態文件以及如何管理這些文件之後,請花一些時間here

+0

不,我正在使用默認的settings.py,但添加的數據庫除外。 – 1Up