HTML-страница пользовательского выбора для формы администратора django
Я создал пользовательский html-шаблон с базовыми флажками для выбора значения и возврата значения на страницу администратора Django.
Я уже 100 раз делал, но теперь значение выбранного суперпрофиля не попадает в переменную "selected_value" в admin.py
Оператор if "if request.method == 'POST':" срабатывает, но я продолжаю получать значение "selected_value" как none
Сводит меня с ума, я не могу найти ничего неправильного в коде
Шаблон Html
{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_modify %}
{% block extrahead %}
{{ media }}
{% endblock %}
{% block content %}
<form class="change_superprofile_parent_form" method="POST" class="change_superprofile_parent_form">{% csrf_token %}
{% for superprofile in superprofiles %}
<input type="checkbox" name="superprofile_selected" {{ superprofile.checked }} value="{{ superprofile }}"> {{ superprofile }}<br>
{% endfor %}
<input type="submit" value="Submit">
</form>
{% endblock %}
Django admin.py
def change_superprofile_parent(self, request, queryset):
"""
Action to change the superprofile of the selected
"""
queryset = queryset.values_list("id", flat=True)
if request.method == 'POST':
selected_value = request.POST.getlist('superprofile_selected')
eligible_superprofiles = SuperProfile.objects.filter(status='Active')
return render(
request, 'admin/auth/user/change_superprofile_parent.html', context={
'superprofiles': eligible_superprofiles,
}
)