Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #5996 -- Add a pyscopg2 convertor for SafeUnicode -> unicode. T…

…hanks, remco@diji.biz

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6816 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 348f2cbfc15c3d80ecc35981d1bd980e06435774 1 parent b3db188
Malcolm Tredinnick malcolmt authored
2  django/db/backends/postgresql_psycopg2/base.py
View
@@ -6,6 +6,7 @@
from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures
from django.db.backends.postgresql.operations import DatabaseOperations as PostgresqlDatabaseOperations
+from django.utils.safestring import SafeUnicode
try:
import psycopg2 as Database
import psycopg2.extensions
@@ -17,6 +18,7 @@
IntegrityError = Database.IntegrityError
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
+psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString)
class DatabaseFeatures(BaseDatabaseFeatures):
needs_datetime_string_cast = False
5 tests/modeltests/field_defaults/models.py
View
@@ -48,4 +48,9 @@ def __unicode__(self):
>>> d = now - a.pub_date
>>> d.seconds < 5
True
+
+# make sure that SafeUnicode fields work
+>>> from django.utils.safestring import SafeUnicode
+>>> a.headline = SafeUnicode(u'SafeUnicode Headline')
+>>> a.save()
"""}
Please sign in to comment.
Something went wrong with that request. Please try again.