models.py 905 B

1234567891011121314151617181920212223
  1. import datetime
  2. from django.db import models
  3. from django.utils import timezone
  4. # User class for built-in authentication module
  5. from django.contrib.auth.models import User
  6. class Profile(models.Model):
  7. user = models.OneToOneField(User)
  8. age = models.IntegerField(blank=True, max_length = 3, null=True)
  9. bio = models.CharField(blank=True, max_length =430)
  10. picture_url = models.CharField(blank=True, max_length=256)
  11. followusers = models.ManyToManyField(User,related_name='follow+')
  12. class Posts(models.Model):
  13. post_content=models.CharField(max_length=160,default="none")
  14. user = models.ForeignKey(User,default="none")
  15. date_time=models.DateTimeField(auto_now_add=True)
  16. class Comment(models.Model):
  17. comment_text =models.CharField(max_length=160,default="none")
  18. comment_datetime = models.DateTimeField(auto_now_add=True)
  19. comment_by = models.ForeignKey(Profile)
  20. comment_post=models.ForeignKey(Posts)