from django.db import models
from django.utils import timezone

class Post(models.Model):
    author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    title = models.CharField(max_length=250)
    text = models.TextField()
    created_date = models.DateField(default=timezone.now)
    published_date = models.DateField()

    def published(self):
        self.published_date = timezone.now()

    def __str__(self):
        return self.title
