title: django.db.utils.IntegrityError: NOT NULL constraint failed: users_profile.user_id
body: <p>I am currently working on a project that would take in a users information and store it. My problem is I keep running into this NOT NULL constraint failed with the user id error. I believe this comes from having a null user when the form is trying to save, but don't know what I could do to fix it. I tried using this line:</p>
  
  <pre><code>form.user = Profile.objects.get(user=self.request.user)
  </code></pre>
  
  <p>but it didn't work and gave me this error:</p>
  
  <blockquote>
    <p>NameError at /users/pii/</p>
    
    <p>name 'self' is not defined </p>
  </blockquote>
  
  <p>Any help or advice that would point me in the right direction would be greatly appreciated!</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Profile(models.Model):
  
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      image = models.ImageField(default='default.jpg', upload_to='profile_pics')
      gender = models.CharField(max_length = 1, choices = GENS, default = '')
      birthday = models.DateField(default = '1900-01-01')
      address = AddressField(on_delete=False, blank=True, null=True)
      race = models.CharField(max_length = 2, choices = RACES, default = 'x')
      ethnicity = models.CharField(max_length = 1, choices = ETHNICITIES, default = 'x')
      income = models.CharField(max_length = 1, choices = INCBRACKET, default = 'x')
      education = models.CharField(max_length = 2, choices = EDUCATION, default = 'x')
      employment = models.CharField(max_length = 1, choices = EMPLOYMENT, default = 'x')
  
      def __str__(self):
          return f'{self.user.username} Profile'
      def save(self, *args, **kawrgs):
          super().save(*args, **kawrgs)
          img = Image.open(self.image.path)
          if img.height &gt; 300 or img.width &gt; 300:
              output_size = (300, 300)
              img.thumbnail(output_size)
              img.save(self.image.path)
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def PII(request):
      if request.method == 'POST':
          form = PIIForm(request.POST,)
          if form.is_valid():
              form.save()
              messages.success(request, f'Your account has been created! You are now able to log in')
              return redirect('finalpii')
      else:
          form = PIIForm(request.POST)
      return render(request, 'users/pii.html', {'form':form})
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class PIIForm(forms.ModelForm):
      birthday = forms.DateField()
      class Meta:
          model = Profile
          fields = [
          'gender',
          'birthday',
          'address',
          'race',
          'ethnicity'
          ]
  </code></pre>