healthier/models.py
def save_favorites(food_id, user):
        """ 
        Adds a favoris relation between food_id:<INT> and user:<User object>
        returns a dict in any case, the key "status" is set to True only on succesful transaction
        """
        try:
            f = Food_item.objects.get(id=food_id)
            f.favoris.get(username=user.username)
            return {"result": "already existing", "status": False}
        except ObjectDoesNotExist:
            try:
                f.favoris.add(user)
                return {"result": "added", "status": True}
            except:
                return {"result": "unforeseen exception", "status": False}
        else:
            return {"result": "unforeseen exception", "status": False}
 
        Adds a favoris relation between food_id:<INT> and user:<User object>
        returns a dict in any case, the key "status" is set to True only on succesful transaction
        
Adds a favoris relation between food_id: and user:
returns a dict in any case, the key "status" is set to True only on succesful transaction
Adds a favoris relation between food_id : and user : returns a dict in any case the key " status " is set to True only on succesful transaction
def save_favorites(food_id, user):
        try:
            f = Food_item.objects.get(id=food_id)
            f.favoris.get(username=user.username)
            return {"result": "already existing", "status": False}
        except ObjectDoesNotExist:
            try:
                f.favoris.add(user)
                return {"result": "added", "status": True}
            except:
                return {"result": "unforeseen exception", "status": False}
        else:
            return {"result": "unforeseen exception", "status": False}
def save_favorites ( food_id , user ) : try : f = Food_item . objects . get ( id = food_id ) f . favoris . get ( username = user . username ) return { "result" : "already existing" , "status" : False } except ObjectDoesNotExist : try : f . favoris . add ( user ) return { "result" : "added" , "status" : True } except : return { "result" : "unforeseen exception" , "status" : False } else : return { "result" : "unforeseen exception" , "status" : False }
Adds a favoris relation between food_id:<INT> and user:<User object>
returns a dict in any case, the key "status" is set to True only on succesful transaction
Adds a favoris relation between food_id : <INT > and user : <User object > returns a dict in any case the key " status " is set to True only on succesful transaction
""" 
        Adds a favoris relation between food_id:<INT> and user:<User object>
        returns a dict in any case, the key "status" is set to True only on succesful transaction
        """
food_id
user