2014-11-07 96 views
1

我的模板文件位于%project%/%app%/templates之类的应用程序目录中,并且在Heroku中定位其他模板文件时没有问题。我现在有一个管理模板%project%/%app%/templates/admin/%app%/%model%/change_list.html,当我在本地浏览管理页面时,模板呈现正常。当我尝试使用Heroku时,我的模板没有显示出来,只显示了默认的change_list.htmlDjango管理模板覆盖'change_list'在Heroku上无法工作

我没有其他模板问题,并试图将模板放在%project%/templates/的根目录下。

这里是我的模板配置:

BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] 
TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader', 
        'django.template.loaders.app_directories.Loader' 
) 

我也使用grappelli如果该事项。

任何人都知道可能会发生什么?

回答

3

为了加载自己change-list模板,你必须把它添加到你的管理模式:

#admin.py 
from django.contrib import admin 

class AuthorAdmin(admin.ModelAdmin): 
    change_list_template = 'admin/author/change_list.html' 
    list_display = ('name','age',) 

您将需要templates目录下创建author/change_list.html。更多信息here在官方的Django文档页面。

+0

这最终在Heroku上工作 - 谢谢! – Spencer 2014-11-07 19:08:55