#5996: psycopg2 raises "can't adapt" error where other backends work happily
-----------------------+----------------------------------------------------
Reporter: zgoda | Owner: nobody
Status: new | Component: Database wrapper
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
The description is vague, but I have only vague idea on what's going on.
The problem does not manifests itself with sqlite3 and psycopg backends.
I have a model with !CharField. Supplying (perfectly valid) unicode object
that contains non-ASCII character to this field causes the psycopg2 to
raise "Can't adapt" error on saving object. The traceback I get from
ipython is like this:
{{{
/home/zgoda/www/zgodowie/blog/models.py in save(self)
42 if not self.slug:
43 self.slug = slughifi(self.title)
---> 44 super(Label, self).save()
45
46
/home/zgoda/www/.python/lib/python2.4/site-
packages/django/db/models/base.py in save(self, raw)
257 cursor.execute("INSERT INTO %s (%s) VALUES (%s)" %
\
258 (qn(self._meta.db_table),
','.join(field_names),
--> 259 ','.join(placeholders)), db_values)
260 else:
261 # Create a new record with defaults for
everything.
ProgrammingError: can't adapt
}}}
It does not matter if I do a `force_unicode()` on `slughifi()` output, the
error is the same.
The definition for the model is as follows:
{{{
class Label(models.Model):
title = models.CharField(max_length=80, unique=True)
slug = models.CharField(max_length=80, editable=False)
description = models.TextField(null=True, blank=True)
def save(self):
if not self.slug:
self.slug = slughifi(self.title)
super(Label, self).save()
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/5996>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---