<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save(self, *args, **kwargs):
 """ This method should be called when is_valid is true to save relevant fields to user and profile models. """

        for key, value in self.cleaned_data.items():
            if value != None:
                if hasattr(self.user, key):
                    setattr(self.user, key, value)
                if hasattr(self.profile, key):
                    setattr(self.profile, key, value)

        # set password
        if 'password1' in self.cleaned_data:
            if self.cleaned_data['password1']:
                self.user.set_password(self.cleaned_data['password1'])

        # set dob
        if 'dob_day' in self.cleaned_data and 'dob_month' in self.\
                cleaned_data and 'dob_year' in self.cleaned_data:
            self.profile.dob = self._gen_dob()

        self.user.save()
        self.profile.save()