title: Getting RelatedObjectDoesNotExist error accessing field on custom form
body: <p>I'm relatively new to Django (and python in general) and I'm working on project I have not coded myself.</p>
  <p>Specifically I'm trying to save some information from a form via <code>POST</code> but I get a <code>RelatedObjectDoesNotExist</code> error when accessing the <code>user</code> field defined in my custom <code>Profile</code> model and I don't get why.</p>
  <p>Here is my <code>views.py</code>:</p>
  <pre class="lang-python prettyprint-override"><code>def conferma(request):
      family = request.user.profile.family  # cannot be null
      already_confirmed = request.user.profile.conferma_inviata
  
      if(already_confirmed == False):
  
          ProfileFormSet = modelformset_factory(
              Profile, form=ConfirmForm, extra=0)
  
          if request.method == 'POST':
              formset = ProfileFormSet(
                  request.POST, queryset=Profile.objects.filter(family=family))
              if formset.is_valid():
                  for form in formset:
                      f = form.save(commit=False)
                      f.conferma_inviata = True
                      f.save()
  </code></pre>
  <p>If I try to access <code>f.user</code> I get a <code>RelatedObjectDoesNotExist</code> error and I need that information in order to save the form.</p>
  <p>Here is my forms.py:</p>
  <pre class="lang-python prettyprint-override"><code>class ConfirmForm(forms.ModelForm):
      class Meta:
          model = Profile
          fields = ('user', 'conferma_pranzo',
                    'conferma_sera', 'conferma_inviata',)
  
      def __init__(self, *args, **kwargs):
          super(ConfirmForm, self).__init__(*args, **kwargs)
          self.fields['user'].required = False
          self.fields['conferma_inviata'].required = False
  </code></pre>
  <p>Here is my <code>models.py</code>:</p>
  <pre class="lang-python prettyprint-override"><code>class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      full_day = models.BooleanField(default=True)
      family = models.TextField(max_length=100, blank=True)
      conferma_pranzo = models.BooleanField(default=False)
      conferma_sera = models.BooleanField(default=False)
      conferma_inviata = models.BooleanField(default=False)
  
      def __str__(self):
          return self.user.first_name + ' ' + self.user.last_name
  </code></pre>
  <p>I have already checked the Database but the <code>Profile</code> records are correctly stored with the proper <code>userd_id</code> reference.</p>
  <p>What am I doing wrong?</p>
  <p>EDIT This is the traceback when I try to view the <code>user</code> field on the form via variable inspector of the debugger:</p>
  <pre class="lang-python prettyprint-override"><code>Traceback (most recent call last):
    File &quot;/home/simone/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py&quot;, line 193, in _get_py_dictionary
      attr = getattr(var, name)
    File &quot;/home/simone/.local/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py&quot;, line 198, in __get__
      &quot;%s has no %s.&quot; % (self.field.model.__name__, self.field.name)
  invitations.models.Profile.user.RelatedObjectDoesNotExist: Profile has no user.
  </code></pre>