I get this error 'int' object has no attribute 'save' when i try to asign a new integer value to a field in my model. I have tried chaging the int to str(250) but i want it to be an integer and not a string
profile_id = request.session.get('ref_profile')
if profile_id is not None:
recommended_by_profile = Profile.objects.get(id=profile_id)
print(profile_id)
p1 = recommended_by_profile.indirect_ref_earning + 250
p1.save()
>Solution :
You should do (assuming that indirect_ref_earning is an IntegerField on Profile model):
profile_id = request.session.get('ref_profile')
if profile_id is not None:
recommended_by_profile = Profile.objects.get(id=profile_id)
print(profile_id)
recommended_by_profile.indirect_ref_earning += 250
recommended_by_profile.save()