Working with Django

Django

Just a post to say that I’ve recently started working with the Django Python web framework. Using Python for the web is a totally new form of web programming for me which I’m finding quite an interesting challenge.

It’s defiantly a lot different to the way PHP works and will take me some getting used to but once I’ve mastered it it should result in more powerful web applications.

Here is some Python Django code (that creates several models) for anyone that’s interested:

class Person(models.Model):
    name = models.CharField(max_length=128)
 
    def __unicode__(self):
        return self.name
 
class Group(models.Model):
    name = models.CharField(max_length=128)
    members = models.ManyToManyField(Person, through='Membership')
 
    def __unicode__(self):
        return self.name
 
class Membership(models.Model):
    person = models.ForeignKey(Person)
    group = models.ForeignKey(Group)
    date_joined = models.DateField()
    invite_reason = models.CharField(max_length=64)

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *

This site uses Akismet to reduce spam. Learn how your comment data is processed.