title: Django many-to-one relationship: NOT NULL constraint failed
body: <p>I'm trying to add data to many-to-one relationship tables.</p>
  
  <pre><code># models.py
  class Exp(models.Model):
      name = models.CharField(max_length=20)
  
  class Analysis(models.Model):
      run = models.ForeignKey(Run)
  
  
  # my_management_command.py
  experiment = Exp(name='sss')
  analysis = Analysis(run=experiment)
  analysis.save()
  </code></pre>
  
  <p>It works fine in the admin page, but in my management command it fails upon attempt to save:</p>
  
  <pre><code>django.db.utils.IntegrityError: NOT NULL constraint failed: webint_analysis.exp_id
  </code></pre>
  
  <p>Why is it complaining about the id and how to fix that?
  Note that I deleted my db to ensure that this is NOT related to migration.</p>