How to program button in Django admin?

Good day,

I can not understand how to put action on the button in Django admin
Override change_list.html for models:
{% extends "admin/change_list.html" %}
{% load i18n admin_urls %}

{% block object-tools %}
 {% if has_add_permission %}
 <ul class="object-tools">
 {% block object-tools-items %}
the <li>
 <button type="submit" name="getShard" value="getShard" class="button">Get Shard</button>
the <li>
 <button type="submit" name="refreshShard" value="refreshShard" class="button">Refresh the Shard</button>
 {% endblock %}
 {% endif %}
{% endblock %}

Wrote in conditional functions:
def getShard():

def refreshShard():

Please tell me how to associate functions with the buttons? Or where can I see the material on the topic?
July 8th 19 at 12:02
3 answers
July 8th 19 at 12:04
so after the pass inaction. instead, write the redirect pass at least
I understand that 'pass' empty function, it's just an example. I can not understand how, in principle, to associate a button and funzio - Elmer.Jacobson34 commented on July 8th 19 at 12:07
July 8th 19 at 12:06
Thanks, but I already studied all I could find in Google, including on this request.

I apologize if not correctly asked a question:

I have API which gives JSON. According to the API documentation, I created some models and now I want to configure updating and retrieval database. For this I wrote a few functions in application and made changes to the template change_list.html adding to the corresponding button. Now I can't understand how can I associate a function from my_app/ and a button from myapp/templates/admin/myapp/mymodel/change_list.html

I would be grateful for response - Elmer.Jacobson34 commented on July 8th 19 at 12:09
for a start
and the json to the built-in admin interface? - Elmer.Jacobson34 commented on July 8th 19 at 12:12
July 8th 19 at 12:08
class MyModelAdmin(admin.ModelAdmin):
 def get_urls(self):
 urls = super().get_urls()
 shard_urls = [
 url(r'^get_shard/$', getShard),
 url(r'^refresh_shard/$', refreshShard),
 return shard_urls + urls

Find more questions by tags PythonDjango