Opened 16 years ago
Closed 16 years ago
#10428 closed (duplicate)
django.utils.dateformat: unknown encoding: gbk2312
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
when the system locale is set to "zh_CN.GBK2312", following error pop up when using DateFormat to format a datetime:
Original Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.3/site-packages/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/usr/lib/python2.3/site-packages/django/template/__init__.py", line 559, in resolve new_obj = func(obj, *arg_vals) File "/usr/lib/python2.3/site-packages/django/template/defaultfilters.py", line 668, in date return format(value, arg) File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 263, in format df = DateFormat(value) File "/usr/lib/python2.3/site-packages/django/utils/dateformat.py", line 114, in __init__ self.timezone = LocalTimezone(dt) File "/usr/lib/python2.3/site-packages/django/utils/tzinfo.py", line 41, in __init__ self._tzname = self.tzname(dt) File "/usr/lib/python2.3/site-packages/django/utils/tzinfo.py", line 60, in tzname return smart_unicode(time.tzname[self._isdst(dt)], DEFAULT_ENCODING) File "/usr/lib/python2.3/site-packages/django/utils/encoding.py", line 35, in smart_unicode return force_unicode(s, encoding, strings_only, errors) File "/usr/lib/python2.3/site-packages/django/utils/encoding.py", line 68, in force_unicode s = s.decode(encoding, errors) LookupError: unknown encoding: gbk2312
Sample Code:
import os import datetime import django.utils.dateformat os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' d = datetime.datetime.now() print d df = django.utils.dateformat.DateFormat(d)
Note:
See TracTickets
for help on using tickets.
Duplicate of #10335