Aug-10-2022, 02:53 PM
I have a stand-alone app and a corresponding api. The idea is to consume the api in a browser extension. I can utilize the objects from a GET request in the app's views like so:
The challenge now is accessing/serializing
Meanwhile DRF's context seem not to work for this use case.
1 2 3 4 5 6 7 |
def room(request, room): username = request.session.get( "user_name" ) if username: room_details = Room.objects.get(name = room) message = Message.objects. all () return render(request, 'room.html' , { 'room' : room, 'message' : message}) |
request.session.get("user_name")
or any other object of request
on the client side when I want to fetch the endpoint. I need to be able to do this also to check user authentication in the browser extension (not using DRF's auth for this).Meanwhile DRF's context seem not to work for this use case.