开发者

Django-Get Current User In Save Time

How Can I Get Current User When I Want Save Som开发者_如何转开发ething In Django Admin. I Mean When Overriding Save Method???


How do you mean? Do you always want to get current user when you override the Model.save() method, or when you save in Admin?

If you override the ModelAdmin.save_model(...) method you have access to the request, and thus the request.user, which is current user.

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜