Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'int' object has no attribute 'save' in Django?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading