Failed to extends User form in django
<p>The error I get is: extend user to a custom form, the "user_id" field is my custom form is the "property", which is linked to the table "auth_user" is not saved, and I need both tables relate to make use my custom form attributes and shape of the User of django.</p>

<p>my models.py</p>

<pre><code>from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.db import models

# Create your models here.
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    Matricula = models.CharField(max_length=25)
</code></pre>

<p>forms.py</p>

<pre><code>   class SignupForm(forms.ModelForm):
   class Meta:
       model = Profile
       fields = ('first_name', 'last_name', 'Matricula')

      #Saving user data
   def signup(self, request, user):
       user.first_name = self.cleaned_data['first_name']
       user.last_name = self.cleaned_data['last_name']
       user.Matricula = self.cleaned_data['Matricula']
       user.save()

       ##Save profile

       profile = Profile()
       Profile.user = user
       profile.Matricula = self.cleaned_data['Matricula']
       profile.save()
</code></pre>

<p>i tried:</p>

<pre><code>user = models.OneToOneField(User, on_delete=models.CASCADE)
</code></pre>

<p>but I get an error: 
<a href="http://i.stack.imgur.com/AevyD.png" rel="nofollow">Error</a></p>

<p>You believe that ForeignKey can be used or correct use OneToOneField?</p>

<p>You should be careful with your capitalisation. You've assigned the user value to the class, not the instance. It should be:</p>

<pre><code>profile = Profile()
profile.user = user
</code></pre>

<p>Or better:</p>

<pre><code>profile = Profile(user=user)
</code></pre>

python django user