How can I handle this error, its driving me crazy:
unsupported operand type(s) for +: 'NoneType' and 'NoneType'
Also
unsupported operand type(s) for +: 'Float' and 'NoneType'
I get what its telling me (I think) so this is the code I wrote to try and battle it
View:
session = request.session._session_key
ind = signedup.objects.filter(sessionid = session)
team = team_signup.objects.filter(sessionid = session)
combine = list(chain(ind, team))
check = signedup.objects.filter(sessionid = session).count() + team_signup.objects.filter(sessionid = session).count()
ind = signedup.objects.filter(sessionid = session).aggregate(Sum ('price'))['price__sum']
team = team_signup.objects.filter(sessionid = session).aggregate(Sum ('price'))['price__sum']
if check == 0:
carttotal = 0.00
elif ind == None:
ind = 0.00
elif team == None:
team = 0.00
carttotal = ind + team
return render_to_response("cart.html",locals(),context_instance = RequestContext(request))
I figured what I was doing was setting their values to 0 before adding it up if it happened to be come up with none as a value. Is there another way to handle this so that when one of them does come up none, it gets set to zero so it can be added. Also when BOTH come up to none they can be set to 0 so that they can be added.