title: How to save form data to different models with one-to-one relationship in Django
body: <p>This is actually a follow-up to a <a href="https://stackoverflow.com/questions/3933997/re-using-set-of-model-fields-in-django">previous question</a>.</p>
  
  <p>A user's profile data is spread over several different models, like so:</p>
  
  <pre><code># Simplified versions, actual classes contain many more fields.
  
  class Profile(models.Model):  # returned by Django's User.get_profile()
      user = models.OneToOneField(User)  
  
      home_address = models.OneToOneField(Address)
      work_address = models.OneToOneField(Address)
  
      language = models.CharField(max_length=20)
  
  class Address(models.Model):
      street = models.CharField(max_length=100)
      city = models.CharField(max_length=100)
  </code></pre>
  
  <p>... and Django's <code>User</code>, of course.</p>
  
  <p>I want the user to enter all of his profile data in one view, in particular these pieces of information:</p>
  
  <ul>
  <li>username (User)</li>
  <li>email (User)</li>
  <li>language (Profile)</li>
  <li>home_address.street (Address)</li>
  <li>home_address.city (Address)</li>
  <li>work_address.street (Address)</li>
  <li>work_address.city (Address)</li>
  </ul>
  
  <p>So, what would be the simplest/Django way to </p>
  
  <ol>
  <li>construct such a form?</li>
  <li>output the form in the template?</li>
  <li>handle the incoming form data, split it to different models and create the necessary objects (i.e. a <code>User</code>, a <code>Profile</code> and 2 <code>Address</code> objects)?</li>
  </ol>