<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_or_create_profile(self, user, save=False, **kwargs):
 """ Return a profile from DB or if there is none, create a new one. :param user: A user object :param save: If set, a new profile will be saved. :type save: bool """

        try:
            profile = self.get_model().objects.get(user=user, **kwargs)
            return profile, False
        except self.get_model().DoesNotExist:
            profile = self.create_profile(user, save=save, **kwargs)
            return profile, True