Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

models.py 600B

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