Closed bingoku closed 7 years ago
我也遇到这个问题,我是这样解决了
def build_attrs(self, base_attrs, extra_attrs=None# , **kwargs):
"Helper function for building an attribute dictionary."
attrs = base_attrs.copy()
if extra_attrs is not None:
attrs.update(extra_attrs)
return attrs
Django 1.9
def build_attrs(self, extra_attrs=None, **kwargs):
"Helper function for building an attribute dictionary."
attrs = dict(self.attrs, **kwargs)
if extra_attrs:
attrs.update(extra_attrs)
return attrs
Django 1.11
def build_attrs(self, base_attrs, extra_attrs=None):
"Helper function for building an attribute dictionary."
attrs = base_attrs.copy()
if extra_attrs is not None:
attrs.update(extra_attrs)
return attrs
Modify xadmin/views/dashboard.py,
def render(self, name, value, attrs=None):
print "!!!!!!!!xadmin\ view\ dashboard.py name is", name, ", attrs is", attrs
if value is None:
value = ''
#final_attrs = self.build_attrs(attrs, name=name)
attrs.update({u'name':name})
final_attrs = self.build_attrs(attrs)
本地测试环境
出现的错误
Error during template rendering
In template /Users/nibuw/.pyenv/versions/devops/lib/python3.6/site-packages/crispy_forms/templates/bootstrap3/field.html, error at line 28
build_attrs() got an unexpected keyword argument 'name'