diff --git a/innovate/forms.py b/innovate/forms.py index 9b6c54c..80cde77 100644 --- a/innovate/forms.py +++ b/innovate/forms.py @@ -21,10 +21,10 @@ class CompetitorForm(forms.ModelForm): CompetitorFormset = modelformset_factory( Competitor, form=CompetitorForm, - min_num=2, max_num=4, extra=0) + min_num=2, max_num=4) class TeamForm(forms.ModelForm): - name = forms.CharField(required=False, label="Team Name (Optional)", widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'BusinessX'})) + name = forms.CharField(required=False, label="Team Name", widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'BusinessX'})) reciept = forms.FileField(required=False) class Meta: diff --git a/innovate/views.py b/innovate/views.py index 1b9ce8e..db563b3 100644 --- a/innovate/views.py +++ b/innovate/views.py @@ -13,7 +13,7 @@ def home(request): return render(request, 'innovate/index.html') def signup(request): - formset = CompetitorFormset() + formset = CompetitorFormset(queryset=Competitor.objects.none()) team_form = TeamForm() if request.method == 'POST': @@ -30,10 +30,11 @@ def signup(request): county = form.cleaned_data.get('school') if name and email and school and county: m = Competitor(name=name, email=email, school=school, county=county, is_leader=is_leader, team=team) - m.save() is_leader = False members.append(m) - send_confirmation(request, team,members) + send_confirmation(request, team, members) + for m in members: + m.save() return redirect('landing') return render(request, 'innovate/signup.html', {'formset': formset, 'team_form': team_form})