from django import forms from django.shortcuts import redirect from lliga.models import * class MenuForm(forms.Form): lliga = forms.ModelChoiceField(queryset=Lliga.objects.all()) def menu(request): form = MenuForm() if request.method == "POST": form = MenuForm(request.POST) if form.is_valid(): lliga = form.cleaned_data.get("lliga") # cridem a /classificacio/ return redirect('classificacio',lliga.id) return render(request, "menu.html",{ "form": form, })