Need help creating a form

23 views
Skip to first unread message

Ben Gorman

unread,
Mar 7, 2015, 7:55:52 PM3/7/15
to django...@googlegroups.com
Note: I've also posted this question StackOverflow but sadly, it hasn't been answered yet.

My setup consists of a League which can contains multiple Teams.  I'm trying to build a form for setting up a (single or double) elimination style tournament.  

Example:
League1 consists of teams A, B, C, and D

I'd like to create a form that has one "general" field for choosing the tournament style (Single Elimination or Double Elimination) and a field for each team in the league to determine their initial seeding in the tournament.  Something like

Style: choice field - {single or double elimination}
Seed1: choice field - {TeamA or TeamB or TeamC or TeamD}
Seed2: choice field - {TeamA or TeamB or TeamC or TeamD}
Seed3: choice field - {TeamA or TeamB or TeamC or TeamD}
Seed4: choice field - {TeamA or TeamB or TeamC or TeamD}
I assume I'll need to make use of formsets, but I can't figure out how to rig everything up correctly.  Can anyone lend me a hand?
My models.py looks like 
class League(models.Model):
    league_name = models.CharField(max_length=60)

class Team(models.Model):
    league = models.ForeignKey('League')
    team_name = models.CharField(max_length=60)
Many thanks
Reply all
Reply to author
Forward
0 new messages