这是我的代码:
class Invitation(models.Model):
#other fields here
Code = models.CharField(max_length=128, null=True, blank=True)
Tags = models.ManyToManyField("CategorieInvitation", null=True, blank=True)
Tags = models.ManyToManyField("Usage", null=True, blank=True)
Note = models.CharField(max_length=128, null=True, blank=True)
Used = models.BooleanField(default=False, blank=True)
SendTo = models.EmailField(null=True, blank=True)
# a revoir
def post_save(self, model_instance, add):
if self.Code.__len__() == 0 :
self.Code = generate_invitation(1)[0]
self.save()
如果 Code 为空白或 null,即使在 django-admin 界面中创建,如何将 Code 替换为 generate_invitation 的结果?
问候比西尔