Reputation: 3
I have a django model like this :
class Post(models.Model):
pub_date = models.DateTimeField(auto_now_add=True)
featured = models.booleanField(default=False)
num = models.IntegerField(defualt = 0, null=True,blank=True)
def save(self,*args,**kwargs):
if self.featured is not None:
self.pub_date = timezone.now()
self.featured = False
self.num = ++1
super (Post,self).save(*args,**kwargs)
Infact I want to add number in my num field when the timezone is updated
but this line self.num = ++1
isn't working
Upvotes: 0
Views: 177
Reputation: 1527
Python does not support ++
operation and does not use it in that way. Fix your code like this.
self.num = ++1 # (X)
self.num += 1 # (O)
Upvotes: 1