I am writing a django giftcardredeem, everything works apart from after adding my worth of the giftcard I cannot save the value
class GiftCardRedeem(FormView):
model = GiftCard
form_class = GiftCardCheck
template_name = 'site/redeem.html'
success_url = '/settings/redeem'
def form_valid(self, form):
MessageForm = form.save(commit=False)
one_entry = GiftCard.objects.get(code=form.cleaned_data['code'])
currentbal = self.request.user.userprofile.balance
totalbal = int(currentbal) + int(one_entry.worth)
print self.request.user.userprofile.balance
totalbal.save()
Error:
'int' object has no attribute 'save'
.save() is for saving objects not parts of objects/individual fields. Instead of trying to save the value - add the value to the user object and then save that.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments