Index: django/db/backends/postgresql/operations.py
===================================================================
--- django/db/backends/postgresql/operations.py (revision 13402)
+++ django/db/backends/postgresql/operations.py (working copy)
@@ -56,7 +56,7 @@
     def last_insert_id(self, cursor, table_name, pk_name):
         # Use pg_get_serial_sequence to get the underlying sequence name
         # from the table name and column name (available since PostgreSQL 8)
-        cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('%s','%s'))" % (table_name, pk_name))
+        cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('\"%s\"','%s'))" % (table_name, pk_name))
         return cursor.fetchone()[0]
 
     def no_limit_value(self):
@@ -96,7 +96,7 @@
                     # This will be the case if it's an m2m using an autogenerated
                     # intermediate table (see BaseDatabaseIntrospection.sequence_list)
                     column_name = 'id'
-                sql.append("%s setval(pg_get_serial_sequence('%s','%s'), 1, false);" % \
+                sql.append("%s setval(pg_get_serial_sequence('\"%s\"','%s'), 1, false);" % \
                     (style.SQL_KEYWORD('SELECT'),
                     style.SQL_TABLE(table_name),
                     style.SQL_FIELD(column_name))
@@ -118,7 +118,7 @@
 
             for f in model._meta.local_fields:
                 if isinstance(f, models.AutoField):
-                    output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
+                    output.append("%s setval(pg_get_serial_sequence('\"%s\"','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                         (style.SQL_KEYWORD('SELECT'),
                         style.SQL_TABLE(model._meta.db_table),
                         style.SQL_FIELD(f.column),
@@ -130,7 +130,7 @@
                     break # Only one AutoField is allowed per model, so don't bother continuing.
             for f in model._meta.many_to_many:
                 if not f.rel.through:
-                    output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
+                    output.append("%s setval(pg_get_serial_sequence('\"%s\"','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
                         (style.SQL_KEYWORD('SELECT'),
                         style.SQL_TABLE(model._meta.db_table),
                         style.SQL_FIELD('id'),
