Django/Python - Получить значение радиобаттона

У меня проблема, я хочу получить значение radiobutton в моем представлении, но я не знаю как. Сейчас у меня есть следующее:

index.html

<form class="card" action="" method="POST" enctype="multipart/form-data">
    {% csrf_token %}
        <input type="radio" name="update_type" value={{view.choice1}}> Choice1 </input>

        <input type="radio" name="update_type" value={{view.choice2}}> Choice2</input>

                    <a href="{% url 'core:newview' slug=???? %}" class="btn btn-primary">Update</a>
                </div>
            </div>
        </div>
    </div>
</form>

views.py

#index.html
class view1(generic.TemplateView):
    extra_context = {"main_page": "active"}
    choice1 = 1
    choice2 = 0
    context_object_name = 'mainview'
    template_name = 'core/index.html'


class NewView(generic.TemplateView):
    extra_context = {"mainx_page": "active"}
    context_object_name = 'newview'
    template_name = 'core/index.html'

    def get(self, request, queryset=None, *args, **kwargs):

        update_choice = self.kwargs.get('slug')

        print(update_choice)

        return redirect(reverse("core:mainview"))

urls.py

path('mailbox/mainview', login_required(views.MainView.as_view()), name='mainview'),
path('mailbox/newview/<int:slug>/', login_required(views.NewView.as_view()), name='newview')

В принципе, я не знаю, что я должен поместить в то место в index.html, где сейчас находятся ????. Я хочу получить 0 в качестве значения из self.kwargs.get('slug'), когда выбор1 выбран в radiobutton и 1, когда выбор2 выбран.

<

Мог бы кто-нибудь помочь мне, буду очень признателен!

Вернуться на верх