Пользовательский HTML-шаблон Django не возвращает никаких значений в admin.py
Я создал пользовательский html-шаблон с базовыми флажками для выбора значения и возврата значения на страницу администратора Django.
Значение выбранного суперпрофиля не захватывается переменной "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" met`your text`hod="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): """ Действие для изменения суперпрофиля выбранного """ 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,
}
)
'''