Save User Session & referrer to it within Dash & Django

@delsim, understand this is a complex problem. django-plotly-dash is an amazing project with many use cases that make it the right choice for most projects. My only argument is there are pro’s and cons to setting up dash within Django’s ORM directly.

In regards to performance, the complexity of the project for which I’ve been building needed me to think outside the box. I’m trying to build an interactive map that’s capable of hosting thousands of geo-locatable icons. When selected open up to full pages providing context on the location. Creating 563+ pages that’s only coverng ~1% of the world isn’t ideal… Figure if I was able to run one separate dash application to manage everything with the use of pages I could build a better frontend/mobile-friendly experience. I’ve at least wanted to test my hypothesis and rethink an alternative option for connecting Django & Dash to the only option currently available. After much frustration, I’ve actually been able to get something working! Check out this post for context.

Basically, the best way I’ve been able to set up the application’s relationship is solely through the FastAPI established with ninja, I’m using two validators. Curious where I could go to investigate the log files more in-depth, but with the way, I currently have it set up the username and password are only half the authentication. It was required to be sent to unlock the HttpBasicAuth within the API and it just runs a test on the user input to see if they have entered a username or an email and to log them into django. Then I’ve also have a set of tokens to represent their login state within the application, this token and their username is the only thing that gets sent back to dash through the setup of cookies in the application to save the user data and to create the relationship.

I’ve opened up the inspector and tried looking into dash but the only cookies I see are basic default cookies provided within dash, not sure how someone would be able to get the password of other people in this setup. I’ve been unable to find the cookies within the application itself and it’s a part of the reason I had so much trouble creating the relationship between the two applications. My solution was with the use of another @callback on top of the validator forum @callback that is run within dash at the start of rendering each page, is the only way I’ve been able to extract the cookie token within the dash application. I’m only able to the cookie from that point forward, on the basis of an initial @callback within the individual pages I’ve set up for example the profile page I built. It is displaying Django data through the API into dash this way:

Example of dash application reading django


These are the only cookies I can see publicly through the inspector, yet i know this isn’t true… maybe dash is hiding them internally?:

Inspecting Dash cookies

Maybe this isn’t the correct path to move forward with… I’m always open to change when appropriate. Really appreciate the insight and response. Just trying to experiment and see if what I’m looking to achieve is possible, have gotten further than I would have thought possible. Trying to compile what I’ve learned and see if their is value we can gain out from the hours I’ve put into learning these complex topics.