Tôi cần triển khai UUID làm khóa chính nhưng tôi không chắc chắn cách thực hiện trong Django.Thực hiện UUID làm khóa chính
Mã của tôi
class LinkRenewAd(models.Model): # This model will generate the uuid for the ad renew link
def make_uuid(self):
return str(uuid.uuid1().int>>64)
uuid = models.CharField(max_length=36, primary_key=True, default=make_uuid, editable=False)
main = models.ForeignKey(Main)
expiration_date = models.DateTimeField()
date_inserted = models.DateTimeField(auto_now_add=True)
date_last_update = models.DateTimeField(auto_now=True)
Khi tôi cố gắng để tạo ra mô hình mới này vào Nam tôi đã nhận lỗi:
TypeError: make_uuid() takes exactly 1 argument (0 given)
+1: Cảm ơn các liên kết đến các phiên bản dcramer. –