I'm trying to make it so that this email will send only if the boolean field is true. Unfortunately, I'm constantly getting invalid syntax errors.
in models.py
class PurchaseOrder(models.Model):
has_responded = models.BooleanField(default = True)
confirmed = models.NullBooleanField(null=True)
in views.py
def confirm(request, itemnum):
item = get_object_or_404(PurchaseOrder, item_number = itemnum)
item.confirmed = True
item.save()
confirm_title = 'Purchase Order %s Confirmed' % item.product
send_mail(confirm_title, 'Check the Product Order System to see the updated list.', 'myemail@gmail.com',['youremail@gmail.com'], fail_silently=False)
return HttpResponse('Product %s confirmed' % item.product )
I would like to make it where has_responded is defaulted to True. And then do an if statement where def confirm will only perform when has_responded is True. At the end of the def, I want to make has_responded to false. Therefore, it'll only perform once. unfortunately, I'm constantly getting errors and I have no idea why. The code above all works, but when I implement the if statement it just falls apart.
EDIT:
This is the code giving me the errors
def confirm(request, itemnum):
item = get_object_or_404(PurchaseOrder, item_number = itemnum)
if item.has_responded == True
item.confirmed = True
item.save()
confirm_title = 'Purchase Order %s Confirmed' % item.product
send_mail(confirm_title, 'Check the Product Order System to see the updated list.', 'myemail@gmail.com',['youremail@gmail.com'], fail_silently=False)
return HttpResponse('Product %s confirmed' % item.product )
item.has_responded = False