setting csrf token in front-end framework forms (such as react forms)

There is a way of creating a view with @ensure_csrf_token to add a csrf token in cookies, and then calling this view before submitting forms every time, to add given token in form or request header.

But the problem of this approach is that we should do a request before submitting every form, which is not a good idea.

So is there any other way, like using {% csrf_token %} in front-end form, to add a csrf automatically, without any extra request?

My understanding is that the csrf token cookie will continue to be exchanged with every POST request and response. You can (usually) get the token from the cookie.

In other words, instead of:
GET
POST
GET
POST
GET
POST,

the sequence becomes:
GET
POST
POST
POST

See How to use Django’s CSRF protection | Django documentation | Django