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 527B

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