#28040: SplitArrayWidget isn't updated for template-based widget rendering
----------------------------------+------------------------------------
     Reporter:  Dariusz Paluch    |                    Owner:  nobody
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  1.11
     Severity:  Release blocker   |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------

Old description:

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

New description:

 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 = ''
 {{{

--

Comment (by dpaluch-rp):

 I add traceback to description, and way I fix this

--
Ticket URL: <https://code.djangoproject.com/ticket/28040#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d2e910c9f26fb951fe4fda230496b0eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to