【发布时间】:2015-07-15 11:22:57
【问题描述】:
@receiver(post_save, sender=StudentActionModel)
def save_student_activity(sender, instance, **kwargs):
# update the model object with some info from the request object
instance.came_from = request.REQUEST.get('request_came_from')
instance.save()
用户故事:用户点击某处,我们正在记录他的操作。我们能否以某种方式访问原始请求对象,以便从中提取一些必需的信息?
问题:我们无法更改 StudentActionModel 代码,我们正在为原始 Django 应用程序编写插件,并且无法更改任何原始代码。我们只是为“post_save”信号定义了一个监听器,我们需要来自原始请求对象的一段数据。
【问题讨论】:
标签: python django django-signals