Posted By

Affix on 01/10/11


Tagged

django


Versions (?)

Django tut Blog model Complete


 / Published in: Python
 

URL: http://affix.me

  1. from django.db import models
  2.  
  3. # Create your models here.
  4. class Category(models.Model):
  5. category_title = models.CharField(max_length=200)
  6. def __unicode__(self):
  7. return self.category_title
  8.  
  9. class Post(models.Model):
  10. entry_title = models.CharField(max_length=200)
  11. entry_content = models.TextField(max_length=5000)
  12. entry_category = models.ForeignKey(Category)
  13. def __unicode__(self):
  14. return self.entry_title
  15.  
  16. class Comment(models.Model):
  17. comment_author = models.CharField(max_length=200)
  18. author_email = models.CharField(max_length=200)
  19. author_web = models.CharField(max_length=200)
  20. post_id = models.ForeignKey(Post)
  21. comment_content = models.TextField(max_length=500)
  22. def __unicode__(self):
  23. return self.comment_author

Report this snippet  

You need to login to post a comment.