0

我正在尝试将 django-simple-history 插件与 django 1.10 版一起使用

根据文档:

  1. 使用以下命令安装插件:

    pip install django-simple-history  
    
  2. 将 simple_history 添加到 INSTALLED_APPS

    INSTALLED_APPS = [  
        ...  
        'simple_history',  
    ]  
    
  3. 要跟踪模型的历史记录,请在模型上创建一个 simple_history.models.HistoricalRecords 实例:

    class ModelClass(models.Model):  
        name1 = models.CharField(max_length=300)  
        name2 = models.CharField(max_length=300)  
        name3 = models.CharField(max_length=300)  
        history = HistoricalRecords(table_name='sampls_modelclass_history')  
        class Meta:  
            db_table = "sample_modelclass"  
    
  4. 为了允许在 Django 管理站点上查看以前的模型版本,在向管理站点注册模型时继承自 simple_history.admin.SimpleHistoryAdmin 类:

    from django.contrib import admin  
    from simple_history.admin import SimpleHistoryAdmin  
    from .models import ModelClass  
    admin.site.register(ModelClass, SimpleHistoryAdmin)  
    
  5. 当我尝试在管理员中的特定 ModelClass 实例上输入“历史记录”时,出现以下异常:

    TypeError: render() got an unexpected keyword argument 'dictionary'  
    

追溯:

Environment:  
Request Method: GET  
Request URL: http://127.0.0.1:8000/admin/org/modelclass/1/history/  
Django Version: 1.10  
Python Version: 2.7.11  
Installed Applications:  
['etc',  
 'org',  
 'django.contrib.admin',  
 'django.contrib.auth',  
 'django.contrib.contenttypes',  
 'django.contrib.sessions',  
 'django.contrib.messages',  
 'django.contrib.staticfiles',  
 'simple_history']  
Installed Middleware:  
['django.middleware.security.SecurityMiddleware',  
 'django.contrib.sessions.middleware.SessionMiddleware',  
 'django.middleware.common.CommonMiddleware',  
 'django.middleware.csrf.CsrfViewMiddleware',  
 'django.contrib.auth.middleware.AuthenticationMiddleware',  
 'django.contrib.messages.middleware.MessageMiddleware',  
 'django.middleware.clickjacking.XFrameOptionsMiddleware']  
**Traceback:**  
File "C:\Python27\lib\site-packages\django\core\handlers\exception.py" in inner  
  39.             response = get_response(request)  
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response  
  187.                 response = self.process_exception_by_middleware(e, request)  
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response  
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)  
File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in wrapper  
  544.                 return self.admin_site.admin_view(view)(*args, **kwargs)  
File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view  
  149.                     response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func  
  57.         response = view_func(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in inner  
  211.             return view(request, *args, **kwargs)
File "C:\Python27\lib\site-packages\simple_history\admin.py" in history_view  
  79.                       dictionary=context, current_app=request.current_app)  
Exception Type: TypeError at /admin/org/modelclass/1/history/  
Exception Value: render() got an unexpected keyword argument 'dictionary'  

请指教解决方法!

4

1 回答 1

0

该参数在 Django 1.10 中被删除。您使用的软件包似乎与该版本不兼容。

于 2016-08-27T10:09:18.817 回答