fix: fixed signup datafill glitch

This commit is contained in:
Rushil Umaretiya 2021-02-18 17:42:42 -05:00
parent 0725c84f02
commit f279e51724
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
2 changed files with 6 additions and 5 deletions

View File

@ -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:

View File

@ -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)
for m in members:
m.save()
return redirect('landing')
return render(request, 'innovate/signup.html', {'formset': formset, 'team_form': team_form})