I'm developing a webpage. I have a login form in this webpage. I'm using Django for back-end and VueJS for front-end. To submit the form with Django, the requirement of Django is the CSRF Token. I currently can show the CSRF Token to HTML using {{ csrf_token }}
.
Because I am using VueJS, I also use Vuetify to style the front-end. The CSRF Token is not visible to VueJS because VueJS doesn't recognize {{ csrf_token }}
but HTML does.
After researching on the internet I found something. I tried using v-bind to give the CSRF Token from HTML to VueJS but unfurtunately the value of the v-bind is undefined. But if I go to my sourcecode (Ctrl+U), I can see that CSRF Toekn does work but VueJS does not recognize it.
Example:
<div id="LoginApp">
<WJLogin
v-bind:csrf="8cl33zQ8pYXXEMVCoSsqIzaFgQkLh6WYXqsQMN4z9X4oGkSGN8Thz922jQ19aG4B"
v-bind:hello="world">
</WJLogin>
</div>
When I use v-bind from VueJS to VueJS this works but from HTML to VueJS doesn't work
This is login.html
<div id="LoginApp">
<WJLogin
:csrf="{{csrf_token}}"
:hello="world">
</WJLogin>
</div>
This is WJLogin.vue
export default
{
props: {
csrf: String,
hello: {
type: String,
default: "defaultValue"
},
},
..............
............
I expect the value of CSRF Token is accesable to VueJS.