Get current user log in signal in Django

后端 未结 6 1786
忘掉有多难
忘掉有多难 2021-02-05 10:01

I am just using the admin site in Django. I have 2 Django signals (pre_save and post_save). I would like to have the username of the current user. How would I do that? It does n

6条回答
  •  终归单人心
    2021-02-05 10:16

    You can use a middleware to store the current user: http://djangosnippets.org/snippets/2179/

    Then you would be able to get the user with get_current_user()

提交回复
热议问题