Opened 8 years ago

Last modified 8 years ago

#28040 closed Bug

SplitArrayWidget isn't updated for template-based widget rendering — at Version 3

Reported by: Dariusz Paluch Owned by: nobody
Component: contrib.postgres Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by dpaluch-rp)

Error: AttributeError: 'SplitArrayWidget' object has no attribute 'template_name'.

Traceback:

Template error:
In template /home/vagrant/apps/pg/python/templates/shared/partials/structure.html, error at line 0
   'SplitArrayWidget' object has no attribute 'template_name'   1 : {% load static_files %}
   2 : {% spaceless %}
   3 : <!DOCTYPE html>
   4 : <html lang="pl" itemscope itemtype="http://schema.org/Organization" {% block html_attrs %}{% endblock html_attrs %} {% block tracking_scripts %}data-pg="google-tag-manager" data-config-google-tag-manager="googleTagManager"{% endblock tracking_scripts %}>
   5 :     <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
   6 :         <meta charset="utf-8">
   7 :         <meta http-equiv="X-UA-Compatible" content="IE=edge">
   8 :         {% block head %}
   9 : 
   10 :             {% block meta %}


Traceback:

File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in render
  107.             self.content = self.rendered_content

File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in rendered_content
  84.         content = template.render(context, self._request)

File "/usr/local/lib/python3.4/dist-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  207.                     return self._render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/loader_tags.py" in render
  177.             return compiled_parent._render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/defaulttags.py" in render
  411.         return strip_spaces_between_tags(self.nodelist.render(context).strip())

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/loader_tags.py" in render
  72.                 result = block.nodelist.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render
  990.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/base.py" in render_annotated
  957.             return self.render(context)

File "/usr/local/lib/python3.4/dist-packages/django/template/library.py" in render
  225.         _dict = self.func(*resolved_args, **resolved_kwargs)

File "/home/vagrant/apps/pg/python/apps/shared/forms/templatetags/forms.py" in render_field
  85.     if not field:

File "/usr/local/lib/python3.4/dist-packages/django/forms/boundfield.py" in __len__
  64.         return len(self.subwidgets)

File "/usr/local/lib/python3.4/dist-packages/django/utils/functional.py" in __get__
  35.         res = instance.__dict__[self.name] = self.func(instance)

File "/usr/local/lib/python3.4/dist-packages/django/forms/boundfield.py" in subwidgets
  57.             for widget in self.field.widget.subwidgets(self.html_name, self.value(), attrs=attrs)

File "/usr/local/lib/python3.4/dist-packages/django/forms/boundfield.py" in <genexpr>
  56.             BoundWidget(self.field.widget, widget, self.form.renderer)

File "/usr/local/lib/python3.4/dist-packages/django/forms/widgets.py" in subwidgets
  191.         context = self.get_context(name, value, attrs)

File "/usr/local/lib/python3.4/dist-packages/django/forms/widgets.py" in get_context
  212.             'template_name': self.template_name,

Exception Type: AttributeError at /xxxx/
Exception Value: 'SplitArrayWidget' object has no attribute 'template_name'

I'm temporary fix this in my app by subclass django Widget and add template_name property

from django.contrib.postgres import forms as postgres_forms


class SplitArrayWidget(postgres_forms.SplitArrayWidget):
    template_name = ''
{{{
}}}

Change History (3)

comment:1 by Tim Graham, 8 years ago

Component: Formscontrib.postgres
Description: modified (diff)
Severity: NormalRelease blocker
Summary: AttributeError: 'SplitArrayWidget' object has no attribute 'template_name'SplitArrayWidget isn't updated for template-based widget rendering
Triage Stage: UnreviewedAccepted

comment:2 by Claude Paroz, 8 years ago

Could you provide a more extensive traceback to see where the error occurs?

comment:3 by dpaluch-rp, 8 years ago

Description: modified (diff)

I add traceback to description, and way I fix this

Note: See TracTickets for help on using tickets.
Back to Top