2
django models 自定义方法报错,我这哪里写的有问题?
source link: https://www.v2ex.com/t/849243
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
.....
class Detect(models.Model):
def chioce_id(self):
data = self.objects.all()
id = len(data) + 1
return id
detect_id = models.BigIntegerField(verbose_name='编号',default=chioce_id)
.......
为什么一直报我错呢? 我想弄个可自填可手改的序号, 这方法在类里不能用吗?有别的法吗?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK