i have a problem in this method when i try to call it from another file it saves perfectly in the db and the values are updated (the points are added to the contractor) but i don’t understand how when i call it in another file (other than the first one ) it only save the value inside the method but once it was out of the method the value wasn’t saved it returned back (checked by printing )
def add_points_cont(contractor_id , action_name):
contractor = Contractor.objects.get(id=contractor_id)
action = Action.objects.get(name=action_name)
toBeAdded = action.points
totalPoints = contractor.points+toBeAdded
contractor.points = totalPoints
contractor.save()
you may pass the method another parameter
def add_points_cont(contractor=None , action_name):you pass the contractor into method