Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for Vue and Python #345

Open
negue opened this issue Jan 15, 2022 · 4 comments
Open

Suggestion for Vue and Python #345

negue opened this issue Jan 15, 2022 · 4 comments

Comments

@negue
Copy link

negue commented Jan 15, 2022

Correct me if I'm wrong. As far I understood your process (of serving to the browser is like that)

  • User calls site
  • python responds with a custom generated html file (per target view) that contains everything
  • browser gets this file and loads all other static files (and maybe even the data in another http call? that I don't know yet)
  • vue gets created / bootstrapped and the page is done
  • until the user clicks to a different page the process starts from 0

I think with that the recreation of the vue app on new click might be "ok" right now but its still alot of repeated overhead

What I suggest would be to go the actual "Single Page Application": Vue compiled once to many static files, which includes the templates that were previously done by python but instead in vue itself - and then python would just have to handle the static and data endpoints - no more also creating the templates with that - which means it saves some CPU work per request

the new user flow would be then like this:

  • User calls site
  • python serves the static vue app as is
  • browser gets this file and loads all other static files
  • vue gets created / bootstrapped and the page is done, the vue app itself then gets all the needed data
  • when now the user clicks to navigate to a different page
    • it would only load the lazy static files, and just attach it to the current vue instance (you save the bootstrapping here aswell)

If its already like that then I'm happy that this issue can be closed :D

@github-actions
Copy link

Hello and Welcome to NearBeach. Thank you for submitting your very first issue at NearBeach. We hope to continue to see your support :D

@robotichead
Copy link
Collaborator

This can be done, the only hurdle I know of is getting Vue Router to talk to Django's URLs.

@negue
Copy link
Author

negue commented Jan 16, 2022

When its all statically build and put under (lets say /dist) then django would only need to serve all static files from /dist

But I think I get what you mean, I usually only work with these "routes" like https://mainurl-of-the-dist/#/subroute/subsubroute you probably want to have something like tha? https://mainurl-of-the-dist/subroute/subsubroute so that it just works

But eitherway yes it would need some changes in vue itself to not just switch the html "file" (current way) to just switch the browser path and let vue handle the loading of the needed static files to show things up

@robotichead
Copy link
Collaborator

I've had a small try whilst streaming - as I have not really used Routing before with VueJS, I am going to create a small project to fully understand it before determining how I would implement something like this. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants