I'm am trying to add a reactive Vue js on the frontend and have Django serve the different pages on the backend. But how do you add these guys together?? I have found different ways to do so, but I can't find a good explanation on the why they are tying them together that way. I was hoping for a comprehensive explanation as to how these 2 are added together but also the why? I am still new to both of these frameworks so I am trying to understand not only how to do something but the reason for my doing them. Thanks in advance.
1 Answer
There are many guides on internet about how to use Vue and Django together. I provide you the main differences and a sample link of implementation for each one. There are two main options for that:
- Using Vue in Django templates
- Separating Vue and Django projects
Option 1 is usually used when you want to use vue in some parts of the app or just making some reactive components. Your routes are handled by django and your passing data to frontend by passing data to views. In some cases you're a backend developer and don't want to spend time on frontend so you use this option whenever you need. For implementation check out this link.
Option 2 is when project is large and complex or you prefer to make a SPA (check this link) so you separate frontend and backend projects and interactions between these two is via API. So you run your frontend project separately and routing and other stuff is handled by vue. For implemetaion check out this link.