build_attrs() 使用 django-bootstrap3-datetimepicker 示例获得了意外的关键字参数 'type'

build_attrs() got an unexpected keyword argument 'type' with django-bootstrap3-datetimepicker sample

你好尝试使用 django-bootstrap3-datetimepicker。 第一次我只尝试使用示例表单包,但我遇到了这个错误:

    TypeError at /sample/
build_attrs() got an unexpected keyword argument 'type'
Request Method: GET
Request URL:    http://localhost:8000/sample/
Django Version: 1.11.2
Exception Type: TypeError
Exception Value:    
build_attrs() got an unexpected keyword argument 'type'
Exception Location: C:\git\ATH_intranet\env_p3\lib\site-packages\bootstrap3_datetime\widgets.py in render, line 110
Python Executable:  C:\git\ATH_intranet\env_p3\Scripts\python.exe
Python Version: 3.6.1
Python Path:    
['c:\git\ATH_intranet',
 'C:\git\ATH_intranet\env_p3\Lib',
 'C:\git\ATH_intranet\env_p3\DLLs',
 'C:\git\ATH_intranet\env_p3\Lib\lib-tk',
 'C:\another-library',
 'C:\git\ATH_intranet\env_p3\Scripts\python36.zip',
 'C:\git\ATH_intranet\env_p3\Scripts',
 'C:\git\ATH_intranet\env_p3',
 'C:\git\ATH_intranet\env_p3\lib\site-packages',
 'C:\git\ATH_intranet\env_p3\lib\site-packages\django_bootstrap3_datetimepicker-2.3-py3.6.egg']
Server time:    jeu, 15 Jui 2017 13:28:05 +0000
Error during template rendering

In template c:\git\ATH_intranet\todo_app\templates\todo_app\template.html, error at line 27
build_attrs() got an unexpected keyword argument 'type'
17                  max-width: 500px;
18              }
19          </style>
20      </head>
21      <body>
22          <form method="post" role="form">
23              {% for field in form.visible_fields %}
24              <div id="div_{{ field.html_name }}" 
25                   class="form-group{% if field.errors %} has-error{% endif %}">
26                  {{ field.label_tag }}
27                  {{ field }}
28                  <div class="text-muted pull-right">
29                      <small>{{ field.help_text }}</small>
30                  </div>
31                  <div class="help-block">
32                      {{ field.errors }}
33                  </div>
34              </div>
35              {% endfor %}
36              {% for hidden in form.hidden_fields %}
37                  {{ hidden }}
Traceback Switch to copy-and-paste view

C:\git\ATH_intranet\env_p3\lib\site-packages\django\core\handlers\exception.py in inner
            response = get_response(request) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\core\handlers\base.py in _get_response
                response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\core\handlers\base.py in _get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
c:\git\ATH_intranet\todo_app\views.py in sample
                  dict(form=form)) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\shortcuts.py in render
    content = loader.render_to_string(template_name, context, request, using=using) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\loader.py in render_to_string
    return template.render(context, request) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\backends\django.py in render
            return self.template.render(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render
                    return self._render(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in _render
        return self.nodelist.render(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render
                bit = node.render_annotated(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render_annotated
            return self.render(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\defaulttags.py in render
                    nodelist.append(node.render_annotated(context)) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render_annotated
            return self.render(context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render
        return render_value_in_context(output, context) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\template\base.py in render_value_in_context
    value = force_text(value) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\utils\encoding.py in force_text
                    s = six.text_type(s) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\utils\html.py in <lambda>
        klass.__str__ = lambda self: mark_safe(klass_str(self)) ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\forms\boundfield.py in __str__
        return self.as_widget() ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\django\forms\boundfield.py in as_widget
            **kwargs ...
▶ Local vars
C:\git\ATH_intranet\env_p3\lib\site-packages\bootstrap3_datetime\widgets.py in render
        input_attrs = self.build_attrs(attrs, type=self.input_type, name=name) ...
▶ Local vars

我在 google 和这个网站上搜索过,但没有结果......请你帮帮我,..

看起来 django-bootstrap3-datetimepicker 还不支持 Django 1.11。您已点击 this issue.

有几个打开的拉取请求 #10 and #12,但尚未合并。

以防万一:django-bootstrap3-datetimepicker 在 https://github.com/tutorcruncher/django-bootstrap3-datetimepicker 分支中支持 Django 1.11。