Reputation: 3554
HI i have a field in database whose value is null = true but i need to update it timely with the integers .I am running this script on terminal
getW = get_HomeTeam_myworld.w
getL = get_HomeTeam_myworld.l
if winloss == "w":
getW = getW + 1
#getW.save()
print getW
but it gives the following error
unsupported operand type(s) for +: 'NoneType' and 'int'
please suggest where i am doing mistake.
Upvotes: 0
Views: 224
Reputation: 3554
ok i fix it actuality we need to save the object
get_HomeTeam_myworld.(save)
Upvotes: 0
Reputation: 3554
tis is right can you also please tell me how can i save this update this value in db
this is the whole process
get_HomeTeam_myworld = myworld.objects.get(team_id=gethome_teamID)
get_HomeTeam_myworld = myworld.objects.get(team_id=getaway_teamID)
getW = get_HomeTeam_myworld.w
getL = get_HomeTeam_myworld.l
if winloss == "w":
getW = getW + 1 if getW else 1
getW.save()
print getW
it gives me the following error
'int' object has no attribute 'save'
Upvotes: 0
Reputation: 3294
It seems like getW value is None. Add some check:
if winloss == "w":
getW = getW + 1 if getW else 1
#getW.save()
print getW
Upvotes: 4