2017-02-01 35 views
0

我在一個項目中使用django smart selectdjango material並獲得從網頁管理員\模板'NoneType' object is not subscriptable \材料\域\ django_relatedfieldwidgetwrapper.html包含Django的材料Django的智能選擇錯誤

{% load material_form material_form_internal material_admin i18n %} 

{% admin_related_field_urls bound_field as bound_field_urls %} 

<div class="related-widget-wrapper"> 
{% render bound_field widget=field.widget.widget %} 
    {% part field label %} 
    <label for="{{ bound_field.id_for_label }}" class="related-widget-label"> 
     <span style="margin-right:5px">{{ bound_field.label }}</span> 
     {% if bound_field_urls.can_change_related %} 
     <a class="related-widget-wrapper-link change-related" 
      data-href-template="{{ bound_field_urls.change_related_template_url }}?{{ bound_field_urls.url_params }}" 
      id="change_id_{{ bound_field.html_name }}" 
      title="{% blocktrans %}Change selected {{ bound_field_urls.model }}{% endblocktrans %}"> 
      <i class="material-icons" style="line-height:16px;font-size:16px">create</i> 
     </a> 
     {% endif %} 
     {% if bound_field_urls.can_add_related %} 
     <a class="related-widget-wrapper-link add-related" 
      href="{{ bound_field_urls.add_related_url }}?{{ bound_field_urls.url_params }}" 
      id="add_id_{{ bound_field.html_name }}" 
      title="{% blocktrans %}Add another {{ bound_field_urls.model }}{% endblocktrans %}"> 
      <i class="material-icons" style="line-height:16px;font-size:16px">add</i> 
     </a> 
     {% endif %} 
     {% if bound_field_urls.can_delete_related %} 
     <a class="related-widget-wrapper-link delete-related" 
      data-href-template="{{ bound_field_urls.delete_related_template_url }}?{{ bound_field_urls.url_params }}" 
      id="add_id_{{ bound_field.html_name }}" 
      title="{% blocktrans %}Delete selected {{ bound_field_urls.model }}{% endblocktrans %}"> 
      <i class="material-icons" style="line-height:16px;font-size:16px">remove</i> 
     </a> 
     {% endif %} 
    </label> 
    {% endpart %} 
    {% part field help_text %}{% endpart%} 
{% endrender %} 
</div> 

回溯:

... 
File "C:\lib\site-packages\django\template\library.py" in render 
    203.   output = self.func(*resolved_args, **resolved_kwargs) 

File "C:\lib\site-packages\material\admin\templatetags\material_admin.py" in admin_related_field_urls 
    296.   'widget': rel_widget.widget.render(bound_field.name, bound_field.value()), 

File "C:\project\smart_selects\widgets.py" in render 
    138.     "id": attrs['id'], 

Exception Type: TypeError at /admin/products/product/add/ 
Exception Value: 'NoneType' object is not subscriptable 

有什麼辦法可以解決這個問題。提前致謝。

+0

請添加一個更好的回溯。 – Udi

+0

請檢查這個http://pastebin.com/Ty0As1Vy – nikolas

回答

0

您在smart_selects\widgets.py有一個bug在你的代碼中,行#138:

File "C:\project\smart_selects\widgets.py" in render 
    138.     "id": attrs['id'], 

(局部變量attrs不是字典,是None)。

+0

通常它工作正常。但是,當添加Django的材料它顯示錯誤 – nikolas

+0

你可以在智能選擇的github回購中提交錯誤。如果你添加了'forms.py'和'models.py',甚至'views.py' – Udi

+0

好的謝謝,你可能有更好的機會得到答案。但是,比django的智能選擇更好的選擇 – nikolas