title: How do you write a save method for forms in django?
body: <p>I have two models in Django: User (pre-defined by Django) and UserProfile. The two are connected via a foreign key. I'm creating a form that allows a customer to edit their user profile. As such, this form will be based on both models mentioned.</p>
  
  <p>How do I create a save() method for this form? What are the steps/requirements in completing the save function?</p>
  
  <p>Here's what I have so far in forms.py:</p>
  
  <pre><code>class UserChangeForm(forms.Form):
      #fields corresponding to User Model
      email = forms.EmailField(required=True)
      first_name = forms.CharField(max_length = 30)
      last_name = forms.CharField(max_length = 30)
      password1 = forms.CharField(max_length=30, widget=forms.PasswordInput)
      password2 = forms.CharField(max_length=30, widget=forms.PasswordInput)
  
      #fields corresponding to UserProfile Model
      gender = forms.CharField(max_length = 30, widget=forms.Select)
      year = forms.CharField(max_length = 30, widget=forms.Select)
      location = forms.CharField(max_length = 30, widget=forms.Select)
  
      class Meta:
          fields = ("username", "email", "password1", "password2", "location", "gender", "year", "first_name", "last_name")
  
      def save(self):
          data = self.cleaned_data
          # What to do next over here?
  </code></pre>
  
  <p>Is this a good start or would anyone recommend changing this up before we start writing the save() function?</p>