Index: django/db/backends/postgresql/operations.py
===================================================================
--- django/db/backends/postgresql/operations.py	(revision 11638)
+++ django/db/backends/postgresql/operations.py	(working copy)
@@ -53,7 +53,7 @@
         return '%s'
 
     def last_insert_id(self, cursor, table_name, pk_name):
-        cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name))
+        cursor.execute("SELECT CURRVAL('\"%s\"')" % get_sequence_name(table_name, pk_name))
         return cursor.fetchone()[0]
 
     def no_limit_value(self):
@@ -90,9 +90,9 @@
                 table_name = sequence_info['table']
                 column_name = sequence_info['column']
                 if column_name and len(column_name) > 0:
-                    sequence_name = '%s_%s_seq' % (table_name, column_name)
+                    sequence_name = get_sequence_name(table_name, column_name)
                 else:
-                    sequence_name = '%s_id_seq' % table_name
+                    sequence_name = get_sequence_name(table_name)
                 sql.append("%s setval('%s', 1, false);" % \
                     (style.SQL_KEYWORD('SELECT'),
                     style.SQL_FIELD(self.quote_name(sequence_name)))
@@ -113,7 +113,7 @@
                 if isinstance(f, models.AutoField):
                     output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                         (style.SQL_KEYWORD('SELECT'),
-                        style.SQL_FIELD(qn('%s_%s_seq' % (model._meta.db_table, f.column))),
+                        style.SQL_FIELD(qn(get_sequence_name(model._meta.db_table, f.column))),
                         style.SQL_FIELD(qn(f.column)),
                         style.SQL_FIELD(qn(f.column)),
                         style.SQL_KEYWORD('IS NOT'),
@@ -124,7 +124,7 @@
                 if not f.rel.through:
                     output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                         (style.SQL_KEYWORD('SELECT'),
-                        style.SQL_FIELD(qn('%s_id_seq' % f.m2m_db_table())),
+                        style.SQL_FIELD(qn(get_sequence_name(f.m2m_db_table()))),
                         style.SQL_FIELD(qn('id')),
                         style.SQL_FIELD(qn('id')),
                         style.SQL_KEYWORD('IS NOT'),
@@ -162,3 +162,11 @@
             if self.postgres_version[0:2] == (8,2):
                 if self.postgres_version[2] is None or self.postgres_version[2] <= 4:
                     raise NotImplementedError('PostgreSQL 8.2 to 8.2.4 is known to have a faulty implementation of %s. Please upgrade your version of PostgreSQL.' % aggregate.sql_function)
+
+
+def get_sequence_name(table_name, field_name='id'):
+    from django.db import connection
+    cursor = connection.cursor()
+    cursor.execute("SELECT pg_get_serial_sequence('%s', '%s')" % (table_name, field_name))
+    seq = cursor.fetchone()[0]
+    return seq.split('.')[1]
