I recieve this kind of error message when in admin:
Caught an exception while rendering: ('ascii', 'Madalal temperatuuril k
\xc3\xbcpsetatud stressivaba sea parim t\xc3\xbckk', 23, 24, 'ordinal
not in range(128)')
The text should actually be "Madalal remperatuuril küpsetatud
stressivaba sea parim tükk".
The model, that saves this information is:
class Retsept(models.Model):
name = models.CharField(max_length=100, verbose_name=_("Name"),
blank=False, null=False)
and other fields....
And the form for it is:
class RetseptForm(ModelForm):
about = forms.CharField(widget=TinyMCE(attrs={'style': 'width:370px',
'rows': 15, 'theme':"simple"}), label = _("text here"),
required=False)
tags = TagField(label = _("tags"),
widget=TagAutocomplete(attrs={'class':'required'}))
name = forms.CharField(label = _("Name"),
widget=forms.TextInput(attrs={'class':'required'}))
class Meta:
model = Retsept
fields = ('name', 'about', 'image', 'tags',)
widgets = {
'name': TextInput(attrs={'class': 'required' })
}
Can anyone tell me whats wrong with it?
Alan
---Peter Herndon
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
Or maybe the default characterset is declared incorrectly.
I think that something is trying to convert a unicode object to an
ascii object (because perhaps the default character set is ascii),
and characters like these don't have ascii representations. Or
something is trying to use a utf-8 string under the presumption
that it is ascii. Rendering to the web should probably be rendering
utf-8.
Are there custom template tags involved?
Bill
Hello
I recieve this kind of error message when in admin:
Caught an exception while rendering: ('ascii', 'Madalal temperatuuril k
\xc3\xbcpsetatud stressivaba sea parim t\xc3\xbckk', 23, 24, 'ordinal
not in range(128)')
The text should actually be "Madalal remperatuuril küpsetatud
stressivaba sea parim tükk".
The model, that saves this information is:
I sometime faced this issue when the data were not properly formatted in the database.
I mean, there was stored in the database through another system that did not handle correctly charset conversions.
Sometime one stores unicodes or iso-8859-xx and says it is utf-8 or whatever.
What could possibly help us is to get the part of code where you extract the data from the form and store them in the model.
Regards,
Xavier.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
and database is:
MySQL charset: UTF-8 Unicode (utf8)
and collation is utf8_unicode_ci
Whole traceback is:
TemplateSyntaxError at /admin/retsept/vote/
Caught an exception while rendering: ('ascii', 'Sea\xc5\xa1a\xc5\xa1l
\xc3\xb5kk ', 3, 4, 'ordinal not in range(128)')
Request Method: GET
Request URL: http://DOMAIN/admin/retsept/vote/
Exception Type: TemplateSyntaxError
Exception Value:
Caught an exception while rendering: ('ascii', 'Sea\xc5\xa1a\xc5\xa1l
\xc3\xb5kk ', 3, 4, 'ordinal not in range(128)')
Exception Location: /www/apache/domains/HOST/htdocs/django/
Django-1.1.1/django/template/debug.py in render_node, line 81
Python Executable: /usr/local/bin/python
Python Version: 2.6.4
Python Path: ['/www/apache/domains/HOST/htdocs/grill', '/www/apache/
domains/HOST/htdocs', '/www/apache/domains/HOST/htdocs/django/django-
tagging-autocomplete-0.3.1', '/www/apache/domains/HOST/htdocs/django/
tagging-trunk', '/www/apache/domains/HOST/htdocs/django/django-
tinymce-1.5', '/www/apache/domains/HOST/htdocs/django/sorl-
thumbnail-3.2.5', '/www/apache/domains/HOST/htdocs/django/
Django-1.1.1', '/www/apache/domains/HOST/htdocs/cgi-bin', '/usr/local/
lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg', '/usr/local/
lib/python2.6/site-packages/zope.interface-3.5.2-py2.6-freebsd-7.2-
STABLE-amd64.egg', '/usr/local/lib/python2.6/site-packages/flup-1.0.2-
py2.6.egg', '/usr/local/lib/python2.6/site-packages/SQLAlchemy-0.5.5-
py2.6.egg', '/usr/local/lib/python2.6/site-packages/nose-0.10.4-
py2.6.egg', '/usr/local/lib/python2.6/site-packages/
python_dateutil-1.4.1-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/pytz-2009r-py2.6.egg', '/usr/local/lib/python2.6/site-
packages/M2Crypto-0.20-py2.6-freebsd-7.2-STABLE-amd64.egg', '/usr/
local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/local/lib/
python2.6/plat-freebsd7', '/usr/local/lib/python2.6/lib-tk', '/usr/
local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib-dynload',
'/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/
site-packages/Numeric', '/usr/local/lib/python2.6/site-packages/PIL',
'/usr/local/lib/python2.6/site-packages/gtk-2.0']
Server time: neljap., 15 Apr 2010 20:53:03 +0300
Template error
In template /www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/
contrib/admin/templates/admin/change_list.html, error at line 78
Caught an exception while rendering: ('ascii', 'Sea\xc5\xa1a\xc5\xa1l
\xc3\xb5kk ', 3, 4, 'ordinal not in range(128)')
68 {% endif %}
69 {% endblock %}
70
71 <form action="" method="post"{% if cl.formset.is_multipart %}
enctype="multipart/form-data"{% endif %}>
72 {% if cl.formset %}
73 {{ cl.formset.management_form }}
74 {% endif %}
75
76 {% block result_list %}
77 {% if action_form and actions_on_top and
cl.full_result_count %}{% admin_actions %}{% endif %}
78 {% result_list cl %}
79 {% if action_form and actions_on_bottom and
cl.full_result_count %}{% admin_actions %}{% endif %}
80 {% endblock %}
81 {% block pagination %}{% pagination cl %}{% endblock %}
82 </form>
83 </div>
84 </div>
85 {% endblock %}
86
Traceback Switch to copy-and-paste view
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/core/
handlers/base.py in get_response
response = callback(request, *callback_args,
**callback_kwargs) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/contrib/
admin/options.py in wrapper
return self.admin_site.admin_view(view)(*args,
**kwargs) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/views/
decorators/cache.py in _wrapped_view_func
response = view_func(request, *args, **kwargs) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/contrib/
admin/sites.py in inner
return view(request, *args, **kwargs) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/contrib/
admin/options.py in changelist_view
], context, context_instance=context_instance) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/shortcuts/
__init__.py in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
loader.py in render_to_string
return t.render(context_instance) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
return self.nodelist.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
bits.append(self.render_node(node, context)) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
debug.py in render_node
result = node.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
loader_tags.py in render
return compiled_parent.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
return self.nodelist.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
bits.append(self.render_node(node, context)) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
debug.py in render_node
result = node.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
loader_tags.py in render
return compiled_parent.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
return self.nodelist.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
bits.append(self.render_node(node, context)) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
debug.py in render_node
result = node.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
loader_tags.py in render
result = self.nodelist.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
bits.append(self.render_node(node, context)) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
debug.py in render_node
result = node.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
loader_tags.py in render
result = self.nodelist.render(context) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
__init__.py in render
bits.append(self.render_node(node, context)) ...
▶ Local vars
/www/apache/domains/HOST/htdocs/django/Django-1.1.1/django/template/
debug.py in render_node
raise wrapped ...
▶ Local vars
Request information
GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
Variable Value
__utma
'149913952.95436242.1271238658.1271342835.1271353741.3'
__utmb
'149913952.2.10.1271353741'
__utmc
'149913952'
sessionid
'468b34de7eea0d6e9a4694ef5d10bc90'
__utmz
'149913952.1271238658.1.1.utmcsr=(direct)|utmccn=(direct)|
utmcmd=(none)'
META
Variable Value
DOCUMENT_ROOT
'/www/apache/domains/HOST/htdocs'
GATEWAY_INTERFACE
'CGI/1.1'
HTTP_ACCEPT
'application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET
'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
HTTP_ACCEPT_ENCODING
'gzip,deflate,sdch'
HTTP_ACCEPT_LANGUAGE
'en-US,en;q=0.8'
HTTP_CONNECTION
'keep-alive'
HTTP_COOKIE
'__utmz=149913952.1271238658.1.1.utmcsr=(direct)|utmccn=(direct)|
utmcmd=(none); sessionid=468b34de7eea0d6e9a4694ef5d10bc90;
__utma=149913952.95436242.1271238658.1271342835.1271353741.3;
__utmc=149913952; __utmb=149913952.2.10.1271353741'
HTTP_HOST
'DOMAIN'
HTTP_REFERER
'http://DOMAIN/admin/'
HTTP_USER_AGENT
'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML,
like Gecko) Chrome/5.0.342.9 Safari/533.2'
PATH
'/bin:/usr/local/bin:/usr/bin'
PATH_INFO
u'/admin/retsept/vote/'
PATH_TRANSLATED
'/www/apache/domains/HOST/htdocs/admin/retsept/vote/'
QUERY_STRING
''
REDIRECT_STATUS
'200'
REDIRECT_UNIQUE_ID
'S8dSf9W0H7IAAWs2zgA'
REDIRECT_URL
'/admin/retsept/vote/'
REMOTE_ADDR
'84.50.47.52'
REMOTE_PORT
'58274'
REQUEST_METHOD
'GET'
REQUEST_URI
'/admin/retsept/vote/'
SCRIPT_FILENAME
'/www/apache/domains/HOST/htdocs/cgi-bin/django.fcgi'
SCRIPT_NAME
u''
SERVER_ADDR
'213.180.31.178'
SERVER_ADMIN
'a...@elkdata.com'
SERVER_NAME
'HOST'
SERVER_PORT
'80'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SIGNATURE
'<ADDRESS>Apache/1.3.41 Server at HOST Port 80</ADDRESS>\n'
SERVER_SOFTWARE
'Apache/1.3.41 (Unix) mod_fastcgi/2.4.6 PHP/5.2.11 mod_ssl/2.8.31
OpenSSL/0.9.8e'
UNIQUE_ID
'S8dSf9W0H7IAAWs2zgA'
wsgi.errors
<flup.server.fcgi_base.OutputStream object at 0x804453190>
wsgi.input
<flup.server.fcgi_base.InputStream object at 0x80443fe90>
wsgi.multiprocess
False
wsgi.multithread
True
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)
Settings
Using settings module grill.settings
Setting Value
ABSOLUTE_URL_OVERRIDES
{}
ADMINS
()
ADMIN_FOR
()
ADMIN_MEDIA_PREFIX
'/grill/meedia/media/'
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
BANNED_IPS
()
CACHE_BACKEND
'locmem://'
CACHE_MIDDLEWARE_KEY_PREFIX
''
CACHE_MIDDLEWARE_SECONDS
600
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
'mysql'
DATABASE_HOST
''
DATABASE_NAME
'vhost8684s1'
DATABASE_OPTIONS
{}
DATABASE_PASSWORD
'********************'
DATABASE_PORT
''
DATABASE_USER
'vhost8684s1'
DATETIME_FORMAT
'N j, Y, P'
DATE_FORMAT
'N j, Y'
DEBUG
True
DEBUG_PROPAGATE_EXCEPTIONS
False
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL
'gr...@selver.eu'
DEFAULT_INDEX_TABLESPACE
''
DEFAULT_TABLESPACE
''
DISALLOWED_USER_AGENTS
()
EMAIL_HOST
'localhost'
EMAIL_HOST_PASSWORD
'********************'
EMAIL_HOST_USER
''
EMAIL_PORT
25
EMAIL_SUBJECT_PREFIX
'[Django] '
EMAIL_USE_TLS
False
FILE_CHARSET
'utf-8'
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_TEMP_DIR
None
FIXTURE_DIRS
()
FORCE_SCRIPT_NAME
None
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INSTALLED_APPS
['django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites',
'django.contrib.admin', 'tinymce', 'sorl.thumbnail', 'tagging',
'tagging_autocomplete', 'retsept', 'grill.profile']
INTERNAL_IPS
()
LANGUAGES
(('et', 'Estonian'),)
LANGUAGES_BIDI
('he', 'ar', 'fa')
LANGUAGE_CODE
'et'
LANGUAGE_COOKIE_NAME
'django_language'
LOCALE_PATHS
()
LOGIN_REDIRECT_URL
'/profile/'
LOGIN_URL
'/login/'
LOGOUT_REDIRECT_URL
'/'
LOGOUT_URL
'/accounts/logout/'
MANAGERS
()
MEDIA_ROOT
'/www/apache/domains/HOST/htdocs/grill/meedia/'
MEDIA_URL
'http://mekaia.com/grill/meedia/'
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
MONTH_DAY_FORMAT
'F j'
PASSWORD_RESET_TIMEOUT_DAYS
'********************'
PREPEND_WWW
False
PROFANITIES_LIST
'********************'
ROOT_URLCONF
'grill.urls'
SECRET_KEY
'********************'
SEND_BROKEN_LINK_EMAILS
False
SERVER_EMAIL
'root@localhost'
SESSION_COOKIE_AGE
1209600
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
SESSION_COOKIE_PATH
'/'
SESSION_COOKIE_SECURE
False
SESSION_ENGINE
'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
SESSION_FILE_PATH
None
SESSION_SAVE_EVERY_REQUEST
False
SETTINGS_MODULE
'grill.settings'
SITE_ID
1
TAGGING_AUTOCOMPLETE_JS_BASE_URL
'/var/www/media/grill/js/jquery-autocomplete'
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media', 'grill.context.loginform')
TEMPLATE_DEBUG
True
TEMPLATE_DIRS
('/www/apache/domains/HOST/htdocs/grill/templates/',)
TEMPLATE_LOADERS
('django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source')
TEMPLATE_STRING_IF_INVALID
''
TEST_DATABASE_CHARSET
None
TEST_DATABASE_COLLATION
None
TEST_DATABASE_NAME
None
TEST_RUNNER
'django.test.simple.run_tests'
TIME_FORMAT
'P'
TIME_ZONE
'Europe/Tallinn'
TRANSACTIONS_MANAGED
False
URL_VALIDATOR_USER_AGENT
'Django/1.1.1 (http://www.djangoproject.com)'
USE_ETAGS
False
USE_I18N
True
YEAR_MONTH_FORMAT
'F Y'
What i am doing in admin is opening a model administrating view. As
you can see from the beginning of traceback the url is /admin/retsept/
vote. Same happens when i try to change tags created by django-tagging.
Bill
Alan
> ...
>
> read more »
Almost every time I have seen this, it is an issue with the model's
__unicode__ method. Can you post that?
--
DR.
It may be provided by one of your installed apps. What {% load ... %} tags
are there in the template?
And thats it
Alan
No, it's not a builtin, it's part of the default admin - it renders
the changelist.
--
DR.
def __unicode__(self):
return self.name
Alan, can you expand the local vars in a few interesting stack frames, like the
bottom several, and maybe the one in options.py further up, and send just the
stack trace part again?
Bill
On Apr 15, 10:13 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> Got it. It's an inclusion tag with templage change_list_results.html
> . I don't see
> anything suspicious in it. The only things that get rendered are
> rendered simply,
> as just a template variable reference, except for "header.txt" which is filtered
> through capfirst. I'm unaware of any of those needing to convert anything to
> ascii.
>
> Alan, can you expand the local vars in a few interesting stack frames, like the
> bottom several, and maybe the one in options.py further up, and send just the
> stack trace part again?
Sure. Thats alot of stuff though:
http://pastebin.org/152583
Thanks!
alan.
>
> Bill
>
>
>
> On Thu, Apr 15, 2010 at 2:54 PM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> > On Apr 15, 7:52 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> >> I don't find it onhttp://docs.djangoproject.com/en/1.1/ref/templates/builtins/.
If I were you, I'd go find the raise wrapped... in debug.py down at the bottom
of the stack trace, and stick a pdb.set_trace() there. Then (assuming you
do this under manage.py runserver) you can poke around to see what was
being rendered and what's in the context. The exception being wrapped may
have useful information that isn't showing in the stacktrace. If you can find
the actuall line of code that is getting the exception, you may be
able to figure
out why it thinks it has to convert something to ascii (which is probably the
default string encoding, use sys.getdefaultencoding() to find out). Probably
something is applying str() to a unicode object.
I'm sorry that I can't provide a shortcut. Perhaps someone else will.
Bill
Sadly, the problem string doesn't occur at the top level of any of those local
vars. It was worth a shot. It's probably in the context.
If I were you, I'd go find the raise wrapped... in debug.py down at the bottom
of the stack trace, and stick a pdb.set_trace() there. Then (assuming you
do this under manage.py runserver) you can poke around to see what was
being rendered and what's in the context. The exception being wrapped may
have useful information that isn't showing in the stacktrace. If you can find
the actuall line of code that is getting the exception, you may be
able to figure
out why it thinks it has to convert something to ascii (which is probably the
default string encoding, use sys.getdefaultencoding() to find out). Probably
something is applying str() to a unicode object.
I'm sorry that I can't provide a shortcut. Perhaps someone else will.