Ticket #5996: pg_safeunicode.diff
File pg_safeunicode.diff, 1.3 KB (added by , 17 years ago) |
---|
-
django/db/backends/postgresql_psycopg2/base.py
6 6 7 7 from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures 8 8 from django.db.backends.postgresql.operations import DatabaseOperations as PostgresqlDatabaseOperations 9 from django.utils.safestring import SafeUnicode 9 10 try: 10 11 import psycopg2 as Database 11 12 import psycopg2.extensions … … 17 18 IntegrityError = Database.IntegrityError 18 19 19 20 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) 21 psycopg2.extensions.register_adapter(SafeUnicode, psycopg2.extensions.QuotedString) 20 22 21 23 class DatabaseFeatures(BaseDatabaseFeatures): 22 24 needs_datetime_string_cast = False -
tests/modeltests/field_defaults/models.py
48 48 >>> d = now - a.pub_date 49 49 >>> d.seconds < 5 50 50 True 51 52 # make sure that SafeUnicode fields work 53 >>> from django.utils.safestring import SafeUnicode 54 >>> a.headline = SafeUnicode(u'SafeUnicode Headline') 55 >>> a.save() 51 56 """}