阅读背景:

如何不显示created_by字段,而是使用保持unique_together规则的当前用户自动填充它?

来源:互联网 

My model assumes that each User (let's say it's a doctor) can have his own Patients. Hence, the Patient model has a 'created_by' field for the currently logged in User. Each doctor (i.e.User) should only have one Patient with the same first and second name (e.g. John Smith), but a different doctor (i.e. other User) can have again a patient called e.g. John Smith. Hence, I've marked the three fields: first_name, last_name, created_by as unique_together. My model assumes that each User (let's say it's




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: