Black Lives Matter. Please consider donating to Black Girls Code today.

Acces to cookies from Dash app inside Django Framework

I’m a beginner in developing web applications. I made a small application using Django and decided to use Dash for my data visualizations. I used a method shown here on forum - ead’s method.

I have one page that is displayed by Dash on my website. If I use my own data, the Dash app in Django Framework works totally fine. The problem is I have to download data from another server. To reach this I use their API. On their API page it is required to log in, so I made my own ‘log in’ page on my website and pass the username and password to their API. I receive cookies and after that I send them back to users through render method. When I need to download datasets from API I simply attach cookies to every request. It works totally fine when using only Django. Now I have this problem, that I would like to get access to that data within my Dash application. The only problem I have is I cannot access these cookies inside my Dash app file. Is there any solution for that? I need to get cookies that I received in Django request.

Is there any option to get these cookies using some Dash or Flask method?


Problem solved, changes that I’ve made:

In dash application file I put whole page content in dash_page function. In views/dispatcher I called this function with argument request.COOKIES[‘csrftoken’], that sent actual Django session cookie into my dash_page function. Simple as that

1 Like