32290

Django material with django smart select error

Question:

I'm using <a href="https://github.com/digi604/django-smart-selects" rel="nofollow">django smart select</a> and <a href="https://github.com/viewflow/django-material" rel="nofollow">django material</a> in a project and getting 'NoneType' object is not subscriptable from the page admin\templates\material\fields\django_relatedfieldwidgetwrapper.html which contains

{% 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>

Traceback:

... 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

Is there any way to fix the issue. Thanks in advance.

Answer1:

You have a bug in your code, in line #138 in smart_selects\widgets.py:

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

(The local variable attrs is not a dict. It is None)

Recommend

  • Xamarin Forms Disposed Textview
  • Symfony 3 new project error
  • jquery .height() and .width() on span tag gets inconsistent results
  • Failed to update work status Exception in Python Cloud Dataflow
  • Running java programs in one runtime instance
  • Google Cloud Builder - Gradle
  • jQuery-Marquee only working in Firefox
  • Angular 2: is styleUrls relative to the current component?
  • Set value of radio button based on user selected options
  • Is it possible to disable jQuery's mobile responsive design?
  • Iterating over a container bidirectionally
  • reduce/reduce conflicts using ocamlyacc
  • Table striping rows in CSS Grid
  • Angular - routerLinkActive and queryParams handling
  • ZipList with Scalaz
  • Is it possible to get the word under the mouse cursor in a ``?
  • redirect_to root_url and return unless @user.activated
  • abstracting over a collection
  • Floated image with variable width and heading with background image
  • Django invalid literal for int() with base 10
  • Adjust width of select element according to selected option's width
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • Webgrid not refreshing after delete MVC
  • Custom validator control occupying space even though display set to dynamic
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Jquery UI tool tip close icon
  • Change multiple background-images with jQuery
  • Insert into database using onclick function
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Modifying destination and filename of gulp-svg-sprite
  • Change an a tag attribute in JavaScript based on screen width
  • jquery mobile loadPage not working
  • Web-crawler for facebook in python
  • Unanticipated behavior
  • Traverse Array and Display in markup
  • Qt: Run a script BEFORE make
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?