django-simple-history,TemplateDoesNotExist 位于 /admin/shared_models/mannedsetting/1/history/ simple_history/object_history.html

问题描述 投票:0回答:1

我正在使用 django-history-admin

我有模特班

class MannedSetting(BaseModel):
    history = HistoricalRecords()
    class Meta:
        db_table = 't_manned_setting'
    confirm_msg = m.CharField(max_length=400)

然后在admin.py中

from simple_history.admin import SimpleHistoryAdmin
class MannedSettingAdmin(SimpleHistoryAdmin):
    list_display = ["id","confirm_msg"]
admin.site.register(MannedSetting,MannedSettingAdmin)

MannedSetting
实例编辑页面出现历史记录按钮

但是当点击按钮时,出现这个错误。

TemplateDoesNotExist at /admin/shared_models/mannedsetting/1/history/
simple_history/object_history.html
Request Method: GET
Request URL:    http://localhost:8010/admin/shared_models/mannedsetting/1/history/
Django Version: 3.2.7
Exception Type: TemplateDoesNotExist
Exception Value:    
simple_history/object_history.html
Exception Location: /Users/whitebear/.local/share/virtualenvs/cinnamon-admin-mg9y4sUV/lib/python3.9/site-packages/django/template/loader.py, line 19, in get_template
Python Executable:  /Users/whitebear/.local/share/virtualenvs/cinnamon-admin-mg9y4sUV/bin/python
Python Version: 3.9.10
Python Path:    
['/Users/whitebear/MyCode/httproot/s_cdk/myadmin',
 '/Users/whitebear/MyCode/httproot/s_cdk/myadmin/my-shared-models',
 '/Users/whitebear/MyCode/httproot/s_cdk/myadmin/$PYTHONPATH',
 '/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python39.zip',
 '/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9',
 '/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload',
 '/Users/whitebear/.local/share/virtualenvs/cinnamon-admin-mg9y4sUV/lib/python3.9/site-packages']
Server time:    Sat, 12 Feb 2022 22:24:06 +0900
python django django-simple-history
1个回答
3
投票

如果您在设置过程中忘记将

simple_history
添加到项目设置中的
INSTALLED_APPS
,则会出现此错误

INSTALLED_APPS = [
    # ...
    'simple_history',
]

您可以在项目上找到安装说明快速入门

© www.soinside.com 2019 - 2024. All rights reserved.