Django 依赖于请求的模型属性
我想落实这一点:Django 依赖于请求的模型属性,django,django-models,Django,Django Models,我想落实这一点: class Job(models.Model): owner = models.ForeignKey(User) ... @property def mine(self): return owner == request.user 如何访问模型中的请求?如果无法访问模型中的请求,则需要将请求。user作为参数传递给函数。如果无法访问模型中的请求,则需要将请求。user作为参数传递给函数。
class Job(models.Model):
owner = models.ForeignKey(User)
...
@property
def mine(self):
return owner == request.user
如何访问模型中的请求?如果无法访问模型中的请求,则需要将
请求。user
作为参数传递给函数。如果无法访问模型中的请求,则需要将请求。user
作为参数传递给函数。