0
試圖讓一些Django的Django外鍵引用對象或uuid?這裏正確的方法
我有這樣的事情(遺漏等領域)的意義:
class Reservation(Model):
extendedReservation = models.ForeignKey('Reservation', default=None, blank=True, null=True)
是否與extendedReservation創建reserrvation時,指望它一個預定對象或預約ID空/沒有?
那麼應該怎麼辦?(參考對象或UUID):
reservation = Reservation.objects.create(user=forUser, resource=resource, timeFrom=timeFrom, timeTo=timeTo, extendedReservation=extendedReservation)
或
reservation = Reservation.objects.create(user=forUser, resource=resource, timeFrom=timeFrom, timeTo=timeTo, extendedReservation=extendedReservation.uuid)
試一下,它應該是非常明顯的,哪個不會。 – karthikr