title: Django one-to-one relationships in one form
body: <p>I'm trying to make a registration form for a extension of django's user model. It has a two relationships, one to <code>User</code> and <code>Address</code>. The form needs to have all the fields from <code>User</code>, <code>UserDetails</code> and <code>Address</code>. But i'm struggling to get the correct view and form. Just having a <code>ModelForm</code> for <code>UserDetails</code> combined with <code>FormView</code> doesn't add the fields for <code>User</code> and <code>Address</code>.</p>
  
  <pre><code>class User(AbstractBaseUser, PermissionMixin):
      email = models.EmailField(unique=True)
  
  
  class UserDetails(model.Model):
      date_of_birth = models.DateField()
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      address = models.OneToOneField(Address, on_delete=models.CASCADE)
  
  class Address(model.Model):
      field = models.CharField(max_length=100)
      field2 = models.CharField(max_length=100)
  </code></pre>
  
  <p>The form and view look like this:</p>
  
  <pre><code>class UserRegistrationForm(ModelForm):
      class Meta:
          model = Orchestra
          fields = '__all__'
  
  class UserRegistrationView(FormView):
      form_class = UserRegistrationForm
      template_name = 'users/register.html'
  
  &lt;form action="" method="post"&gt;
      {% csrf_token %}
      {{ form.as_table }}
      &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;
  </code></pre>