1. Mikhail Korobov
  2. django-widget-tweaks
Issue #14 duplicate

'SafeText' object has no attribute 'as_widget'

Anonymous created an issue

Hi -

Trying to get this to work, but I'm getting the error below. Something wrong with the field.as_widget setting.

# decorate field.as_widget method with updated attributes
old_as_widget = field.as_widget

def as_widget(self, widget=None, attrs=None, only_initial=False):
            attrs = attrs or {}
            process(widget or self.field.widget, attrs, attribute, value)
            return old_as_widget(widget, attrs, only_initial)

******** The Error *********

AttributeError at /account/profile/

'SafeText' object has no attribute 'as_widget'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/account/profile/
Django Version:     1.6.1
Exception Type:     AttributeError
Exception Value:    

'SafeText' object has no attribute 'as_widget'

Exception Location:     /Library/Python/2.7/site-packages/widget_tweaks/templatetags/widget_tweaks.py in _process_field_attributes, line 22
Python Executable:  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version:     2.7.3
Python Path:    

['/Users/ericmattison/code/portal',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pywkher-1.0.0-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wkhtmltopdf-master-py2.7.egg',
 '/Library/Python/2.7/site-packages/django_tastypie-0.9.12_alpha-py2.7.egg',
 '/Library/Python/2.7/site-packages/mimeparse-0.1.3-py2.7.egg',
 '/Library/Python/2.7/site-packages/django_recaptcha-0.0.5-py2.7.egg',
 '/Library/Python/2.7/site-packages/django_auth_ldap-1.1.2-py2.7.egg',
 '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/python_ldap-2.4.10-py2.7-macosx-10.7-intel.egg',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/Library/Python/2.7/site-packages/requests-0.14.2-py2.7.egg',
 '/Library/Python/2.7/site-packages/virtualenv-1.8.2-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyObjC',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
 '/Library/Python/2.7/site-packages',
 '/Library/Python/2.7/site-packages/PIL']

Server time:    Thu, 13 Feb 2014 15:35:04 -0500
Error during template rendering

In template /Users/ericmattison/code/account/templates/account/generic_form.html, error at line 8
'SafeText' object has no attribute 'as_widget'
1   {% load widget_tweaks %}
2   <form action="." method="post" class="form-horizontal" role="form">
3   {% csrf_token %}
4   
5   {% for field in form %}
6   <div class="form-group">
7   {{ field.errors }}
8   {% render_field field.label_tag class+="col-sm-2 control-label" %}
9   {{ field }}
10  </div>
11  {% endfor %}
12  <div class="form-group">
13  <div class="col-sm-offset-2 col-sm-10">
14  <button type="submit" class="btn btn-default">Save</button>
15  </div>
16  </div>
17  </form>
18  

Comments (3)

  1. Log in to comment