title: Invalid column name 'id' in Django
body: <p>So i'm using Django models in a different way, I have existing tables in MS SQL server and I would like to access them for my application. I've been following some tutorials in pluralsights and also 
  <a href="https://docs.djangoproject.com/en/1.11/howto/legacy-databases/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/1.11/howto/legacy-databases/</a>. I followed the steps accordingly and got my models ready and,when i used 'migrate' command, I got this error </p>
  
  <blockquote>
    <p>“AssertionError: A model can't have more than one AutoField.”</p>
  </blockquote>
  
  <p>So  I looked up SO and got another documentation by Django</p>
  
  <blockquote>
    <p>By default, Django gives each model the following field:</p>
    
    <p>id = models.AutoField(primary_key=True)</p>
    
    <p>This is an auto-incrementing primary key.</p>
    
    <p>If you’d like to specify a custom primary key, just specify
    primary_key=True on one of your fields. If Django sees you’ve
    explicitly set Field.primary_key, it won’t add the automatic id
    column.</p>
    
    <p>Each model requires exactly one field to have primary_key=True (either
    explicitly declared or automatically added).</p>
  </blockquote>
  
  <p>So by his solution, i've added 'id' column to the tables which don't have a primary key and skipped the ones which had.
  And my 'migrate' command worked smooth.</p>
  
  <p>But When I'm trying to test if i can get values from it, it shows  Invalid column 'ID'</p>
  
  <p>Now, I keep thinking myself, if Django creates them implicitly, or when I create it explicitly inside the models( and then using makemigrations and migrate command), shouldn't it have created the column for it?</p>
  
  <p>Another scenario:
  There are some tables with primary key already established, I've tried queries on them and it worked. </p>
  
  <p>This just makes me think if I missed a step inbetween all these,</p>
  
  <p>Here's my  lib files</p>
  
  <pre><code>certifi==2016.2.28
  Django==1.11.3
  django-mssql==1.8
  django-pyodbc-azure==1.11.0.0
  mysqlclient==1.3.12
  PyMySQL==0.7.9
  pyodbc==4.0.17
  pytz==2017.2
  wincertstore==0.2
  </code></pre>
  
  <p>Sorry for the bad formatting, but please help if I had missed any step for connecting with legacy systems.Please do ask if any extra information is needed. Thanks!</p>
  
  <p>Edit: As asked, this is the model where my query worked</p>
  
  <pre><code>class DjangoSession(models.Model):
      session_key = models.CharField(primary_key=True, max_length=40)
      session_data = models.TextField()
      expire_date = models.DateTimeField()
  
      class Meta:
          managed = False
          db_table = 'django_session'
  </code></pre>
  
  <p>And here's the one(Of many) that did not work</p>
  
  <pre><code>class table1(models.Model):
      id=models.AutoField(primary_key=True)
      col2 = models.CharField(db_column='col2', max_length=255, blank=True, null=True)  # Field name made lowercase. Field renamed to remove unsuitable characters.
      col3 = models.IntegerField(db_column='col3', blank=True, null=True)  # Field name made lowercase.
      col4 = models.CharField(max_length=250, blank=True, null=True)
      col5 = models.DateTimeField(db_column='col5')  # Field name made lowercase.
  
      class Meta:
          managed = True
          db_table = 'table1'
  </code></pre>
  
  <p>The session_key variable has been in the table, hence I did not have the need to create a primary key for that table.
  Whereas, the <code>id=models.AutoField(primary_key=True)</code> has been added by me because of various documentations I've read, I've tried the 'implicitly added' method of creating id too, but it gives the same.</p>
  
  <p>The sql shell query that introduced this error:</p>
  
  <pre><code>from app.models import table1
  table1.objects.filter(column_name='col3')
  </code></pre>
  
  <p>The migration.createModel function is as belows</p>
  
  <pre><code>migrations.CreateModel(
              name='VikalpFtrFeatureCr',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('col2', models.CharField(blank=True, db_column='col2', max_length=255, null=True)),
                  ('col3', models.IntegerField(blank=True, db_column='col3', null=True)),
                  ('col4', models.CharField(blank=True, max_length=250, null=True)),
                  ('col5', models.DateTimeField(db_column='UPDATE_DTTM')),
              ],
              options={
                  'managed': False,
                  'db_table': 'VIKALP_FTR_Feature_CR',
              },
          )
  </code></pre>