Hacker News new | ask | show | jobs
by Stephen0xFF 2259 days ago
I feel the only way these two will play nicely is swapping Django for a DRF approach. Vanilla JS could be, and perhaps should be, used in place of Vue for small use cases. There's no need for the extra abstraction when AJAX could work.
2 comments

Well you "could" spit out data from the views as JSON into <script> blocks in the Django templates and they would play nicely together.

But then you would be limited to various manipulations of the initial data so "could" is certainly not "should".

Can’t you also pass data into components by using server side templating to fill in props on the component?

Like this: https://stackoverflow.com/a/56461472

... and that's exactly why I used the word "perhaps" before should. On paper importing a front end framework to a template engine shouldn't be done if you're following software design principles KISS, minimalism, and reducing technical debt. You can always render initial data on server side and maybe you should as business logic lives there.
The thing is, some of my use cases are not that small but still contained to only parts of the project.

Also, jQuery always feels kinda hacky to me. I have a much better feeling with VueJS. Part of this could be owed to the fact that I work on Java Backends in my day job.