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
精彩评论