How can i use csrf token in customised django model admin?

I am working in a simple Django project, and i want to add a button for every model object in admin and i am able to create it by using this:
in admin.py

class RegistrationAdmin(admin.ModelAdmin):
    def button(self, obj):
        isreg = obj.username
        return format_html('<form action="/validate/" method="post">{% csrf_token %}<script>x={{isreg}};</script><button class="btn btn--pill btn--green"'
         ' type="submit">Validate</button></form>', {'isreg': isreg})

    button.short_description = 'Action'
    button.allow_tags = True
    list_display = ['username', 'button']

But when i excute it it gives key error:

KeyError at /admin/myapp/registration/
'% csrf_token %'

so how can resolve this error?
or
is there any other way to add functionality to my validate button?

How can i use csrf token in customised django model admin?