title: Modify Django AutoField start value
body: <p>I have and existing database, which I have migrated with SQLAlchemy to a new PostgreSQL database.</p>
  
  <p>I moved all primary keys with the same values as before. Now I have tables filled with data, but the associated sequences starts from 1. I have pk values stored 1 to 2000.  </p>
  
  <p>Now, when I try to save something with Django, I have the</p>
  
  <blockquote>
    <p>duplicate key value violates unique constraint
    regarding to the Primary Key.</p>
  </blockquote>
  
  <p>How can I modify the sequence start values or escape this situation?<br>
  My current solution is:</p>
  
  <pre><code>conn = psycopg2.connect(...)
      for table_name in table_names:
  
          cursor = conn.cursor()
          cursor.execute("""
          SELECT setval('%s_id_seq', (SELECT COALESCE(MAX(id),0)+1 FROM %s));
          """% (table_name, table_name))
  </code></pre>
  
  <p>It works for me, but I don't like it.</p>