alanjameschapman / whiteboard

django blog for teachers and students
0 stars 1 forks source link

USER STORY: manage available post fields #1

Closed alanjameschapman closed 8 months ago

alanjameschapman commented 8 months ago

As a superuser I can manage available post fields so that I can standardise and structure posts.

Acceptance Criteria

Tasks

alanjameschapman commented 8 months ago

Add to edblog/models.py:

class Post(models.Model):
    """
    Stores a single blog post entry related to :model:`auth.User`.
    """

    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(max_length=200, unique=True)
    author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts')
    content = models.TextField()
    created_on = models.DateTimeField(auto_now_add=True)
    updated_on = models.DateTimeField(auto_now=True)
    status = models.IntegerField(choices=STATUS, default=0)
    excerpt = models.CharField(max_length=200, blank=True)

Add to edblog/admin.py:

admin.site.register(Post)
alanjameschapman commented 8 months ago

Add to Post class in edblog/models.py:

class Meta:
        ordering = ['-created_on', 'author']

    def __str__(self):
        return self.title
Before After
Image Image