Development of an internal social media platform with personalised dashboards for students

models.py 844B

1234567891011121314151617181920212223242526272829
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. from django.utils import timezone
  4. from taggit.managers import TaggableManager
  5. from datetime import datetime
  6. from croniter import croniter
  7. class CustomUser(models.Model):
  8. user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
  9. tags = TaggableManager(blank=True)
  10. class Post(models.Model):
  11. author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
  12. title = models.CharField(max_length=200)
  13. text = models.TextField()
  14. created_date = models.DateTimeField(
  15. default=timezone.now)
  16. published_date = models.DateTimeField(
  17. blank=True, null=True)
  18. tags = TaggableManager()
  19. def publish(self):
  20. self.published_date = timezone.now()
  21. self.save()
  22. def __str__(self):
  23. return self.title