Django tut Blog model Complete


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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

URL: http://affix.me

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.