Archive for October, 2008

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.

Comment on this post

The Geology of Ubuntu

SubtitleUbuntu ROCKS!!!

This morning I got my T-mobile HDSPA card back.  It’s a PCMCIA card which I use to connect to the internet.  I’ve had it for about two years now, and having finally found myself a stable base, have been using it less and less.

Since I last used it, I’ve got myself a new laptop – and it’s running Ubuntu Intrepid.  I was a bit concerned about setting up the datacard, as last time I set it up (circa 9 months ago) it was a bit of a struggle, and I could only use KPPP to connect to network, after entering some arbitary settings.

Today – I plugged in the card.  It was immediately recognised, and libnotify was used to let me know I could configure the card now.  I simply selected my network provider from a drop-down list, and clicked apply.  Thanks to the wonderfulness of Network-Manager applet – I can now simply click on the icon to switch between networks – including my new 3G connection.

It’s streamlining like this that is much harder to do with a proprietary system.  This is all about using the people at the end of the long tail to add their 2 pence worth.

Ubuntu ROCKS!

Comment on this post

Define Blogging without Mentioning Technology

Paul Bradshaw just posted a blog posting the question as to whether it’s possible to define blogging without mentioning technology.

Is it possible?

No, I don’t think so.

As I mentioned in my previous post there are three types of technology:

Replacement technology – that which replaces a process we already have, but makes it easier.

Enabling technology – that which enables us to do things that were either not possible, or too time consuming to be worthwhile before the technology.

Ubitiquous technology – technology that becomes so widely used and pervasive that it becomes a part of the fabric of society, and is taken for granted.

Blogging, I think, has become an ubiquitous technology – not in terms of it’s pervasiveness across society (though I’m sure some would argue for that claim) – but in terms of it’s functionality.  Until blogging became popular, the only people who has access to a mass-audience were journalists.  Blogging has initiated a conversation between people, who are otherwise unconnected.  I don’t twitter to my friends, many of whom view the technology as pointless and ‘geeky’ – however, I do twitter to some folk, from whom I’ve been able to generate business leads, ideas, and other opportunities.  It’s not a pointless task.

So many things happened to allow blogging to take off as it has done.  The idea of ‘planets’ of bloggers give a sense of community, though not always known.  This blog has been submitted to planets with my blessing, and others have added it without my knowledge.  Pingbacks, and comments are the most powerful parts of blogging – the actual ‘blog’ itself is very rarely valuable in itself.  However, with links to other blogs, and a variety of opinions proposed by the readership, a blog can grow into more.

When we talk about ‘things we used to blog’ now appearing on twitter, identi.ca, facebook, flickr .etc – we’re not talking about the blog articles, but the comment and conversation generated from them.  We’ve removed the time-consuming layer of having to set out ones ideas before being able to discuss them.   We’re conversing live, we’re using sources and media – and we’re enjoying it.  As bandwidth increases, people are doing videoblogs, podcasts – all of which are extensions to blogging.  Blogging is a technological marvel – to remove the technology would mean a blog would become an individual’s diary.  In is the ‘interconnectivity of all blogs’ (Douglas Adams would love this) that gives them their value.

Comment on this post

Financial Crisis – Why Paulson’s Plan Stinks! George Soros

Here’s a fantastic article by George Soros on Swamp Politics.

Definately food for though on how decisions like this are made – and the implications of these decisions.

Comment on this post