Django League Table
I'm trying to write a league table for some sport results using django. At the moment my model looks pretty basic:
class Scores(models.Model): matchnum = models.AutoField(primary_key=True) homeuser = models.ForeignKey(User, related_name="hmuser") hometeam = models.ForeignKey('teams', related_name="hmteam") homescore = models.IntegerField() wayuser = models.ForeignKey(User) awayteam = models.ForeignKey('teams') awayscore = models.IntegerField() pub_date = models.DateTimeField(auto_now_add=True, editable=False) def __unicode__(self): id = str(self.matchnum) return id class Meta: verbose_name_plural="Scores"class Teams(models.Model): teamname = models.CharField(max_length=40) def __unicode__(self): return self.teamname class Meta: verbose_name_plural = "Teams"However, with the information in this simple model - I should be able to generate a league table, with the following fields:
| Team | Played # | Won | Drawn | Lost | Goals For | Goals Against | Goal Difference | Points |
|---|
So how to put this into a Django App? Well I need some advice, as my original method was to edit the save() function of the model to input fields into a new model - however, I should be editing things at the form level. I'd also like a 'generate league' method, rather than a method where a league is generated at the end of each score addition. The main advantages of this approach is that I can:
- Generate the League from existing score data.
- Future Users can generate the League from their data.
- Leagues can be generated at the end of each 'gameweek' - rather than just at the end of each game.
Django is a fantastic python framework that I'm immediately getting to grips with - but as this kind of application (simple as it is) - is one that's scalable and may be useful to many other users.. I want to get it right from the start.
I'll be tagging the posts with 'djangoleague' if you want to keep up with development - and if anyone wants to use the project/help me out with it - please post in the comments and I'll get back to you.
Me-ware versus Groupware
I'm sure I'm not alone amongst the ubuntu-uk crowd, in that I run my own mailserver. With ubuntu, it was very easy to set up postfix and cyrus, and retrieve my email via IMAP. The great thing about IMAP is that wherever I am, providing I have an internet connection, I am constantly up to date with my email. It's all out there on 'the cloud' - the buzzword of marketeers in the IT industry in the moment. To have data constantly accessible is fantastic - no need to work about syncronising between different PCs and the like - it's all there 24/7 (unless I throttle my VPS.. which has been known).
I've used squirrelmail, roundcube webmail, horde, and Zimbra on my server over the past two years. The first two are targetted more at the individual email user (though can serve multiple unique accounts), whereas the latter two are groupware suites.. which include tools for collaboration, shared calendaring, shared email, file storage & exchange .etc. However, they were a bit 'overkill' for a server running about 4 mail accounts.
Me-ware
The problem is, that I want the functionality of packages like horde and zimbra - but scaled down to suit me. I want to be able to syncronise my phone with my calendar, I'd love to have a centralised LDAP-based addressbook, which I could other packages to - but I don't need a multi-tiered directory service. You might say I'm being a bit naive... the software is free so why complain when it does loads more than it needs to?
Well, Bongo to you.
Bongo?
Bongo is a project that caught my eye possibly over 12 months ago, when Daviey in #ubuntu-uk gave me a demo. It's a smart looking project, that looks to answer exactly my needs. It looks clean, simple - is open source and sticks to open standards.. so it'll link it with it's bigger cousins (like horde and zimbra) should I want to share calendars .etc.. but it's also targetted at users.. not organisations. 0.5 release is due out before linuxexpo in London, 23-25th October 2008. I intend to keep my eye on it, and hopefully even help out a bit; and get it running my own system aasap.
My programming career begins (with bugfixing).
It's taken me a while, but just over 12 months learning the basics of programming, I'm finally contributing and commiting code to my company's SVN repo.
One of the things I like about programming, is that it seems to suit me. Having not done any programming at all before 12 months ago, jumping in at the deep end and going into a career that requires it wasn't an easy step to take. However, I've had some good guidance from my colleagues - in that I've not settled upon a single language. I wouldn't say I know any language well, but I'm reading and understanding code better than I've done before.
The hardest part for me, is looking at a problem and seeing my own solution - rather than the solution that's coded infront of me. Once I've understood the train of though of the original programmer, it's alot easier.. however, at the start I was failing to do that.
At the moment I'm happy making modifications and bugfixes to programs. It's simply enough stuff, where auditing and testing the problem takes by far the majority of the time. However, I'm understanding things better - and feel like I'm finally making some decent progress.
I know it's possible to contribute to open source in other ways than just coding (I've been doing that for the last few years) - but now I'm coding I hope to submit code to the projects I like. It's been my aim for a while. I've set up my bzr repo, but most of my code at the moment I'd hope to submit as patches to other projects. Who knows what the future will hold.