Opened 16 years ago

Last modified 16 years ago

#10313 closed

TypeError coercing to Unicode on DateTime Field — at Version 1

Reported by: pvickers Owned by: nobody
Component: Uncategorized 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 (last modified by Karen Tracey)

The error I'm getting is
TypeError at /admin/dbasite/dbeventhistory/add/

coercing to Unicode: need string or buffer, datetime.datetime found

This occurs after doing a simple add using the automatically generated code by the Django admin interface.

I'm running Django 1.0, using cx_Oracle to connect to an Oracle database.
The cx_Oracle I have installed is version 5.0.1 but this exact same error also happens using version 4.4.
I have reproduced this error using Oracle 9i and Oracle 10g. On Oracle 10g, I tested using Oracle characterset WE8ISO8859P1 and UTF8 - the error still occurs.

I have a very simple model defined as:

class DBEventHistory(models.Model):
    event_date = models.DateTimeField()
    description = models.CharField(max_length=1024)
    dba = models.ForeignKey(DBA)

    def __unicode__(self):
        return self.event_date

    class Meta:
        db_table = u'DB_EVENT_HISTORY'
        verbose_name_plural = ('DB Event History')

The trace back I get is:

Environment:

Request Method: POST
Request URL: http://cls049:8000/admin/dbasite/dbeventhistory/add/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'dbinfo.dbasite']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in root
  158.                 return self.model_page(request, *url.split('/', 2))
File "/usr/lib/python2.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in model_page
  177.         return admin_obj(request, rest_of_url)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/options.py" in __call__
  191.             return self.add_view(request)
File "/usr/lib/python2.4/site-packages/django/db/transaction.py" in _commit_on_success
  238.                 res = func(*args, **kw)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/options.py" in add_view
  507.                 self.log_addition(request, new_object)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/options.py" in log_addition
  294.             object_repr     = force_unicode(object), 
File "/usr/lib/python2.4/site-packages/django/utils/encoding.py" in force_unicode
  49.                 s = unicode(s)

Exception Type: TypeError at /admin/dbasite/dbeventhistory/add/
Exception Value: coercing to Unicode: need string or buffer, datetime.datetime found

Change History (1)

comment:1 by Karen Tracey, 16 years ago

Description: modified (diff)

[Fixed formatting. Please use preview.]

I really don't think you want to be using cx_oracle

Note: See TracTickets for help on using tickets.
Back to Top