#28040 closed Bug (fixed)
Update SplitArrayWidget to use template-based widget rendering
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 )
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 (9)
comment:1 by , 8 years ago
Component: | Forms → contrib.postgres |
---|---|
Description: | modified (diff) |
Severity: | Normal → Release blocker |
Summary: | AttributeError: 'SplitArrayWidget' object has no attribute 'template_name' → SplitArrayWidget isn't updated for template-based widget rendering |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 8 years ago
comment:3 by , 8 years ago
Description: | modified (diff) |
---|
I add traceback to description, and way I fix this
comment:4 by , 8 years ago
Description: | modified (diff) |
---|
comment:5 by , 8 years ago
What does your form look like? I can't reproduce a crash with a straightforward form like:
from django import forms from django.contrib.postgres.forms import SplitArrayField class Form(forms.ModelForm): tags = SplitArrayField(base_field=forms.CharField(max_length=200), size=3)
comment:6 by , 8 years ago
Has patch: | set |
---|---|
Summary: | SplitArrayWidget isn't updated for template-based widget rendering → Update SplitArrayWidget to use template-based widget rendering |
comment:7 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Could you provide a more extensive traceback to see where the error occurs?