~lfaraone/+junk/spp

« back to all changes in this revision

Viewing changes to main/models.py

  • Committer: Luke Faraone
  • Date: 2011-03-03 23:30:42 UTC
  • Revision ID: luke@faraone.cc-20110303233042-pz4b56chmhl1h2j5
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
from django.db import models
 
4
 
 
5
# Create your models here.
 
6
 
 
7
class Paper(models.Model):
 
8
    title = models.CharField(max_length=255)
 
9
    text = models.TextField()
 
10
    author = models.CharField(max_length=255)
 
11
    def __unicode__(self):
 
12
        return u"«" + self.title + u"» by " + self.author
 
13
 
 
14
class Comment(models.Model):
 
15
    paper = models.ForeignKey(Paper)
 
16
    text = models.TextField()
 
17
    author = models.CharField(max_length=255)
 
18
    date = models.DateTimeField(auto_now=True)
 
19
    def __unicode__(self):
 
20
        return u"Comment on «" + self.paper.title + u"» by " + self.author + " at " + str(self.date)