title: Django ForeignKey null=True fails to drop not null from column
body: <h1>The problem:</h1>
  
  <p>Here's my class with two <code>ForeignKey</code>s (<code>dept</code> and <code>salary_range</code>). Note <code>null=True</code>:</p>
  
  <pre><code>class UserProfile(models.Model):
      user = models.OneToOneField(User, related_name='user_profile')
      avatar = models.CharField(max_length=300, default='/static/default.png')
      dept = models.ForeignKey(Department, null=True)
      salary_range = models.ForeignKey(SalaryRange, null=True)
  </code></pre>
  
  <p>Running <code>python manage.py sqlall main</code> seems show the correct sql (no <code>NOT NULL</code> on <code>dept_id</code> and <code>salary_range_id</code>:</p>
  
  <pre><code>CREATE TABLE "main_userprofile" (
      "id" integer NOT NULL PRIMARY KEY,
      "user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id"),
      "avatar" varchar(300) NOT NULL,
      "dept_id" integer REFERENCES "main_department" ("id"),
      "salary_range_id" integer REFERENCES "main_salaryrange" ("id"),
  </code></pre>
  
  <p>But an <code>IntegrityError</code> occurs when creating a <code>UserProfile</code>:</p>
  
  <pre><code>main_userprofile.dept_id may not be NULL
  </code></pre>
  
  <p>And upon inspection of the database, both columns are set <code>NOT NULL</code>. <strong>How? Why?</strong></p>
  
  <h1>The hack:</h1>
  
  <p>All I have been able to come up with is to alter the table after <code>syncdb</code>:</p>
  
  <pre><code>ALTER TABLE main_userprofile ALTER COLUMN dept_id DROP NOT NULL;
  ALTER TABLE main_userprofile ALTER COLUMN salary_range_id DROP NOT NULL;
  </code></pre>
  
  <p>This works for Postgres, but sqlite does not have an <code>ALTER COLUMN</code> option..</p>
  
  <h1>The Solution ??</h1>