How I can let Django and FastAPI share the context (user) with the orm requests?
So I am writing an app with NiceGUI that is built on FastAPI and with Django.
Right now I have no problem in the FastAPI to call the Django ORM in async to save in the database etc.
The problem is that I am trying to share to the ORM requests that I do also the context
in this way knows who is the user doing the various requests.
I have implemented the login manually with aauthenticate
and works (I save a token in the user model for the auth) but if I call a model like "Product" doens't have the request.context
so I can't use https://github.com/jazzband/django-simple-history/ to save the author of the changes.
I was thinking to create a custom auth middleware but how I can be sure that the ORM requests I will do will get that context?
Another test I was doing was to create a RequestFactory and create a HTTPRequest manually with the session and login
at the end but I have the same doubts.
Another solution could be create a custom history
and not use that package but I have some doubts that the issue will happen again for another reason.