Skip to content

Instantly share code, notes, and snippets.

@aphoenix
Created November 6, 2011 23:56
Show Gist options
  • Save aphoenix/1343820 to your computer and use it in GitHub Desktop.
Save aphoenix/1343820 to your computer and use it in GitHub Desktop.
Some Models
class Book(models.Model):
""" Book Model - an item in the lending library """
title = models.CharField(max_length=200)
author = models.CharField(max_length=100)
genre = models.CharField(max_length=20, blank=True)
def __unicode__(self):
return self.title
class Borrower(models.Model):
""" Borrower Model - who is taking the book """
name = models.CharField(max_length=100)
email = models.EmailField(max_length=255, blank=True)
def __unicode__(self):
return self.name
class Loan(models.Model):
""" Loan Model - matching borrowers to books """
book = models.ForeignKey(Book)
borrower = models.ForeignKey(Borrower)
date_lent = models.DateField(default=datetime.now())
returned = models.BooleanField(default=False)
def __unicode__(self):
return '{0}'.format(self.book)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment