title: How to edit user's profile view with django
body: <p>I am making a form in which the user can edit their profile, so currentley I have 2 forms, one that edits the User model(first_name, Username and Email) and other one that edits the Profile model(biography). The problem is that everytime I edit, just the User model is the one that gets saved while the Profile model doesnt. I think that the error is on the views.py file.</p>
  
  <p>views.py</p>
  
  <pre><code>    def edit_profile(request):
        if request.method == 'POST':
          form = EditProfileForm(request.POST, instance=request.user)
          form1 = UpdateProfileForm(request.POST, instance=request.user)
          if form.is_valid:
            form.save()
            form1.save()
            return redirect('profile')
        else:
          form = EditProfileForm(instance=request.user)
          form1 = UpdateProfileForm(instance=request.user)
          args = {
            'form': form,
            'form1': form1,
            }
          return render(request, 'profile-edit.html', args)
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>    class EditProfileForm(UserChangeForm):
  
        class Meta:
          model = User
          fields = (
            'first_name',
            'username',
            'email',
          )
          exclude = ('password',)
  
      class UpdateProfileForm(forms.ModelForm):
  
        class Meta:
          model = Profile
          fields = (
            'bio',
            'profile_pic',
          )
          exclude = ('user',)
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>    class Profile(models.Model):
        user = models.OneToOneField(User, on_delete=models.CASCADE)
        bio = models.CharField(max_length=400, default=1)
  
        def __str__(self):
          return f'{self.user.username} Profile'
  </code></pre>
  
  <p>profile-edit.html (I replaced the {{form.as_p}} and {{ form1.as_p }} to the following html code)</p>
  
  <pre><code>    &lt;form method="post" enctype="multipart/form-data"&gt;
        {% csrf_token %}
        &lt;div class="edit-profile"&gt;
          &lt;h3&gt;Name&lt;/h3&gt;
          &lt;input type="text" name="first_name" value="{{ user.first_name }}" maxlength="30" id="id_first_name"&gt;
          &lt;h3&gt;Username&lt;/h3&gt;
          &lt;input type="text" name="username" value="{{ user.username }}" maxlength="150" required="" id="id_username"&gt;
          &lt;h3&gt;Bio&lt;/h3&gt;
          &lt;input type="text" name="bio" value="{{ user.profile.bio }}" maxlength="400" id="id_bio"&gt;
          &lt;h3&gt;Email&lt;/h3&gt;
          &lt;input type="email" name="email" value="{{ user.email }}" maxlength="254" id="id_email"&gt;
          &lt;button type="submit"&gt;Submit&lt;/button&gt;
        &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>