3 ms·
This is similar to what I've done recently with a project of mine using Django + Elm (https://github.com/ereadingtool/ereadingtool https://github.com/ereadingto
by alphanumeric0 6y ago
This is similar to what I've done recently with a project of mine using Django + Elm (https://github.com/ereadingtool/ereadingtool https://github.com/ereadingtool/ereadingtool).
I wrote an adapter of sorts, between Django and the frontend, which is a Django base template specifically for the pages loading compiled Elm/JavaScript, that turns Django view context data into a JavaScript data structure that gets fed into the Elm code. In this way, the frontend JavaScript is initialized and ready to go without more page fetches. If I need to pass some extra data to it, I can simply add it in to get_context_data().
I like the idea of re-using everything Django has to offer but also being able to pass a few parameters into Elm and have it handle the view side. Where I get into trouble is when Elm and Django code both have to agree on data formats and schemas, but this is more my fault for not strongly abstracting the API.