Skip to content

Instantly share code, notes, and snippets.

@lqez
Created August 16, 2012 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lqez/3367067 to your computer and use it in GitHub Desktop.
Save lqez/3367067 to your computer and use it in GitHub Desktop.
SAMPLE : webtoon models.py
from django.db import models
from django.contrib.auth.models import User
class Author(models.Model):
name = models.CharField(max_length=200)
desc = models.TextField()
def __unicode__(self):
return self.name
class Comic(models.Model):
title = models.CharField(max_length=200)
author = models.ForeignKey(Author)
desc = models.TextField()
def __unicode__(self):
return self.title
class Episode(models.Model):
title = models.CharField(max_length=200)
comic = models.ForeignKey(Comic)
img_file = models.FileField(upload_to='comics')
pub_date = models.DateTimeField()
def __unicode__(self):
return self.title
class Comment(models.Model):
user = models.ForeignKey(User)
msg = models.CharField(max_length=200)
episode = models.ForeignKey(Episode)
written_date = models.DateTimeField()
def __unicode__(self):
return "%s : %s" % ( self.user.username, self.msg )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment