Django Get ID of the object in save()
问题 I have some fixed number let say it is num = 1000 Now I have field which need to be sum of the object.id and num. I need this in save() something like below. def save(self, *args, **kwargs): num = 1000 self.special = self.id + num super(MyModel, self).save(*args, **kwargs) But self.id is known after save and field named special is required. How to get self.id? 回答1: First of all? Is the number you're trying to add a fixed number? If so, why do you have to store it in the db at all? You may