How Can I Get Current User When I Want Save Something In Django Admin. I Mean When Overriding Save Method???
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 therequest.user, which is current user.https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model