I have some classes related to football (soccer),
I have Player, Team, Fixture, Result, Squad, Squad Selector,
Appearance and Scorer classes.  They way I have modelled it is that A
player belongs to a squad, and each team is picked from a squad (e.g.
a squad may consist of 30 players but a team will only contain 16 at
most but can vary from week to week), a fixture can be added for a
team.  A result is based on a fixture (i.e. it has a fixture
foreignkey) and 2 more fields for the score of the home team, and
score of away team.

The squad selector also has a foriegnkey on fixture, but also has 16
other fields that are all foreignkeys on player.

e.g.
class SquadSelector(models.Model):
  fixture = models.ForeignKey(Fixture, verbose_name="Fixture",
core=True, help_text="Fixture to select squad for.")
  gk = models.ForeignKey(Player, verbose_name="Goal Keeper",
related_name="gk", core=True, help_text="Name of Goal Keeper.")
  rb = models.ForeignKey(Player, verbose_name="Right Back",
related_name="rb", core=True, help_text="Name of Right Back.")
.....
  sub1 = models.ForeignKey(Player, verbose_name="Sub 1",
related_name="sub1", help_text="Name of 1st Sub.")
  sub2 = models.ForeignKey(Player, verbose_name="Sub 2",
related_name="sub2", help_text="Name of 2nd Sub.")
  sub3 = models.ForeignKey(Player, verbose_name="Sub 3",
related_name="sub3", help_text="Name of 3rd Sub.")
  sub4 = models.ForeignKey(Player, verbose_name="Sub 4",
related_name="sub4", help_text="Name of 4th Sub.")
  sub5 = models.ForeignKey(Player, verbose_name="Sub 5",
related_name="sub5", help_text="Name of 5th Sub

Now I have a few queries/questions.
1.)As you can see from the class above I have stated core=True on all
the fields in SquadSelector except subs 1-5 because obviously a team
must have all 11 players, but subs are a possible extra.  Yet still
when I try and leave them blank the admin page says I need to have
them.  How do I stop this from happening?

2.)My appearance class simply contains a result foreignkey and a
player foreignkey, when I go to the admin page I select the result
from a drop down box, then select the player from another drop down
box.  How would I go about making it so that all those players in the
starting 11 (e.g. those not a sub) that were in the squad selector for
that particular fixture, are automatically added to the appearance
admin page? (e.g. so I dont have to add the fixture and player 11
times over?)

3.)How would I go about creating a statistics page (now the classes
are in place) such as player x has 10 appearances, and 3 goals (goals
come from scorer class[result, player, howmany]) I know this is a
basic question regarding views and templates but I'm still very new to
this, I have looked through as much of the documentation as I can but
cannot find anywhere that details what I want?

e.g. I need Player forename, surname, age, sex, squad.name, and then
goals (count of all entries of "how many" where player id = player x's
id), and an appearance number (count of all tuples where player id =
player x's id)

Sorry for being a lame newbie and asking so many questions, but I'm
the type of person who will put as much effort back in helping others
when I have reached a higher level.

Thanks very much in advanced,
Duncan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to