Am Dienstag, 8. Mai 2007 22:54 schrieb Gerard M:
> Thanks for all your help guys, but I'm facing another little thing
> here, if I'm getting the word from a file (this means I'm not typing
> the word directly into the code), for example:

Maybe this helps:

s="München"             # simple string
ustr=s.decode("latin1") # string to unicode
sutf8=ustr.encode("utf8")     # back to simple string, utf8 format

 Thomas

BTW, I modified base.py by looking at the unicode branch. Now my unicode
problems are gone:

--- tmp/django/trunk/django/db/backends/postgresql_psycopg2/base.py     
2007-04-25 10:18:56.000000000 +0200
+++ django/trunk/django/db/backends/postgresql_psycopg2/base.py 2007-05-07 
15:30:21.594113338 +0200
@@ -7,6 +7,7 @@
 from django.db.backends import util
 try:
     import psycopg2 as Database
+    import psycopg2.extensions
 except ImportError, e:
     from django.core.exceptions import ImproperlyConfigured
     raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e
@@ -21,6 +22,8 @@
     # Import copy of _thread_local.py from Python 2.4
     from django.utils._threading_local import local
 
+psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
+
 postgres_version = None
 
 class DatabaseWrapper(local):
@@ -48,6 +51,7 @@
                 conn_string += " port=%s" % settings.DATABASE_PORT
             self.connection = Database.connect(conn_string, **self.options)
             self.connection.set_isolation_level(1) # make transactions 
transparent to all cursors
+            self.connection.set_client_encoding('UTF8')
         cursor = self.connection.cursor()
         cursor.tzinfo_factory = None
         if set_tz:
@@ -150,7 +154,7 @@
                 sql.append("%s %s %s %s %s %s;" % \
                     (style.SQL_KEYWORD('ALTER'),
                      style.SQL_KEYWORD('SEQUENCE'),
-                     style.SQL_FIELD(quote_name('%s_%s_seq' % (table_name, 
column_name))),
+                     style.SQL_FIELD('%s_%s_seq' % (table_name, column_name)),
                      style.SQL_KEYWORD('RESTART'),
                      style.SQL_KEYWORD('WITH'),
                      style.SQL_FIELD('1')
@@ -161,7 +165,7 @@
                 sql.append("%s %s %s %s %s %s;" % \
                     (style.SQL_KEYWORD('ALTER'),
                      style.SQL_KEYWORD('SEQUENCE'),
-                     style.SQL_FIELD(quote_name('%s_id_seq' % table_name)),
+                     style.SQL_FIELD('%s_id_seq' % table_name),
                      style.SQL_KEYWORD('RESTART'),
                      style.SQL_KEYWORD('WITH'),
                      style.SQL_FIELD('1')

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to