Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django.utils import timezone
- import datetime
- from django.contrib.auth.models import User
- """
- The model for each created blog post
- """
- class BlogPost(models.Model):
- title = models.CharField(max_length=50)
- pub_date = models.DateTimeField('date published')
- #publisher = models.ForeignKey(User, User.username) commented out not working
- entry = models.TextField()
- author = models.ForeignKey(User) #another attempt at linking the user creating the blog to the blog post
- def was_published_recently(self):
- """
- query to return the latest pblished blog post
- """
- return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
- def __str__(self):
- return self.title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement