title: Django: Instantiate object with `null` ForeignKey
body: <p>I have two models in my application, <code>A</code>, <code>B</code>.</p>
  
  <p><code>A</code> is supposed to have a one-to-many relationship with <code>B</code>, so <code>B</code> carries a <code>ForeignKey</code> attribute to <code>A</code>.</p>
  
  <p>The relationships however are only establishing after a while, <em>not</em> when objects of <code>B</code> are instantiated. I understand from the documentation that in this case, I'm supposed to use <code>null=True</code> as an argument to the ForeignKey of <code>B</code>. The <code>B</code> table indeed looks like this:</p>
  
  <pre><code>CREATE TABLE "B" (
      "id" integer NOT NULL PRIMARY KEY,
      "name" varchar(128) NOT NULL,
      "applied_with_id" integer REFERENCES "A" ("id")
  )
  ;
  </code></pre>
  
  <p>In my <code>B</code> model, I set the <code>applied_with</code> field as</p>
  
  <pre><code>applied_with = models.ForeignKey('A', null=True)
  </code></pre>
  
  <p>as shown in the Django documentation using a string parameter for the referenced model.</p>
  
  <p>Note that the <code>NOT NULL</code> constraint in <code>applied_with_id</code> is absent by using <code>null=True</code>.</p>
  
  <p>However, when I now go about and create a <code>B</code> object, I get</p>
  
  <pre><code>django.db.utils.IntegrityError: B.applied_with_id may not be NULL
  </code></pre>
  
  <p>I can't understand the reason for this and also, how else does one create one-to-many relationships where the connections only establish after a while?
  I checked related posts about <code>null</code> ForeignKeys here but the only related post seems to be one where <code>updatedb</code> solves the problem (without any model changes). I'm using Django 1.5 and have used the equivalent <code>syncdb</code> but without any success.</p>