Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Get data from Django to Vue Template

I'm trying to get data from Django to Vuetemplate variables.

views.py

def index(request):
  myvar = 1
  return render(request, 'index.html',{'myvar':myvar})

in index.html

<span> {{ myvar }} </span>

Is working, and shows 1, but how can i get this 1/myvar to data inside of the vue instance?

var app = new Vue({
  el: "#app",
  data: { 
// here i need the data/value of myvar
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can grab the value via params of route

var app = new Vue({
  el: "#app",
  data: { 
// here i need the data/value of myvar
   myvar: this.$route.params.myvar
}

about 4 years ago · Juan Pablo Isaza Report

0

var app = new Vue({
  el: "#app",
  data: { 
    myvar: '{{ myvar }}' //myvar comes from django urls.py
}

Works for me, this.$route.params.myvar doesn't cause im not using vuerouter.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!