Created
November 6, 2011 23:56
-
-
Save aphoenix/1343820 to your computer and use it in GitHub Desktop.
Some Models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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