django_blog/blog/models.py
2017-10-29 13:40:42 +03:00

25 lines
649 B
Python

# -*- coding: utf-8 -*-
from django.db import models
from django.utils import timezone
from tinymce.models import HTMLField
from taggit.managers import TaggableManager
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = HTMLField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
tags = TaggableManager(blank=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __unicode__(self):
return self.title