I've recently started on some social media web site using Django. Im using the default django template engine to fill my pages. But at this moment, I want to add javascript to make the site more dynamic. This means:
I want to use Vue to deal with the dynamic components, but I don't know how I should get started. The application should not be a SPA.
{% url 'index' %}
in the dropdown menu.Introduction. Django is a Python-based backend framework used to create native applications or APIs using the Django rest framework package. We can also combine it with Vue. js, a JavaScript-based front-end framework, in building applications.
There you go! Now you've got a working SPA that you can configure and customize to your heart's content. As you can see, using Vue. js with Python takes a bit of getting used to as it involves understanding JavaScript, Python, AND SQL at the same time.
Django is a collection of Python libs allowing you to quickly and efficiently create a quality Web application and is suitable for both frontend and backend.
The short answer. No, you're not doing anything wrong by not-using a frontend framework with Django. There's no unwritten law that everything has to turn into a SPA, or be rewritten from scratch in React. Your project can be awesome without them, and you won't miss out on much.
This looks like an opinion based question for which there is no clear answer.
You mentioned that you do not want the app to be a Single Page Application (SPA). If so, what is the motivation for using Vue? To handle user interactions within page?
Vue can work perfectly alright in non-SPA context. It will help you handle rich interactions within the page, like binding your data to drop-downs, forms, etc. But the real power of Vue comes out when you use it in SPA context.
For your case, I would recommend using Vue.js in standalone mode, where you can quickly define template
within Vue components and write all your code easily in one javascript file.
Here is what you need: https://vuejs.org/guide/installation.html#Standalone
In "Vue.js standalone mode", There is no need for any webpack build system or vue-cli
. You can build the app directly in your existing dev environment for django. gulp
can optionally minify and bundle your javascript files normally, just like you do with your jQuery based apps.
Vue.js uses double curly braces {{..}}
for templates, so it will not interfere with your django template strings.
All the jsFiddle examples for Vue.js run in standalone mode. That is precisely what you need at this moment. You may look at some of the recent questions with vue.js
tag, find a sample jsFiddle and see how it is done.
For complex SPA apps, you need to build your Vue code separately from server side, test it thoroughly with dummy AJAX calls, build it for production and then drop the final production build into your server for end-to-end testing. This is something you can do in future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With