Answer the question
In order to leave comments, you need to log in
How to run vue.js in Django?
Django doesn't work with vue.js. Even a simple Hello world.
view.py:
from django.shortcuts import render
from django.http import HttpResponse
from django.core import serializers
from .models import State
def main(request):
return render(request, 'inspector/vue.html')
def get_state(request):
panel_list = State.objects.all()
data = serializers.serialize('json', panel_list)
return HttpResponse(data, 'application/javascript')
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<p>{{ message }}</p>
</div>
<script type="text/javascript">
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
}
})
</script>
Answer the question
In order to leave comments, you need to log in
Change the type of brackets in vue - does he know how to do this?
Django template
https://docs.djangoproject.com/en/dev/ref/template...
Add delimiters:[''], to the main body of the application or component. Note that all components are independent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question