0

In post_delete of models.signals, I want send a request to other server to notify about this action, but I have a problem when I try to get some info from request.headers(ex: clientId send from client), please help me about this problem Thank you.

vinh vuong hung
  • 51
  • 1
  • 1
  • 6
  • You could try this https://stackoverflow.com/questions/58153911/use-django-request-session-inside-utility-function/58154014#58154014 – Toan Quoc Ho Oct 06 '19 at 07:55
  • I think this is the [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Why do you want to use the request headers in the post_delete of models.signals? If the request headers are relevant, it suggests addressing your use case at the view level if that's practical... – krubo Oct 06 '19 at 20:06

1 Answers1

0

Short answer: you can't access request in a signal by the means of Django. If you absolutely need that, you can use some libraries that provide global access to the request object.

I suggest using this library: django-middleware-global-request. But make sure that there is no native django solutuion first.

Nikita Tonkoskur
  • 1,440
  • 1
  • 16
  • 28