I have a Django app for backend, which renders templates with Vue as frontend. My view code in django has the following parts:
# thing/views.py
def index(request):
template = loader.get_template('thing/index.html')
return HttpResponse(template.render({}, request))
# thing/urls.py
from django.views.generic import TemplateView
urlpatterns = [
path('', TemplateView.as_view(template_name='index.html')),
]
# some other files that complete the project are not included
In index.html
there is the following code:
<div id="app">
<p v-if="quotaRemaining > -1">
Remaining: {{ quotaRemaining }}
</p>
</div>
<script>
const app = new Vue({
el: '#app',
data: {
quotaRemaining: 42,
},
});
</script>
The only thing that is being rendered when I access this page is:
Remaining:
While I would expect it to be
Remaining: 42
Why is my Vue template not being rendered correctly when served by Django? How do I make it work?