BUG: unable to update blogs
1 year, 4 months ago timeenjoyed

need to fix. Just wanted to warn people in case they were thinking to write a blog rofl.

But in the meantime, here's some code I salvaged from an attempted entry... that I'll re-attempt probably.

Just ended a stream where I intended to fix bugs related to the layout of blog entries (markdown and status), but there was an interesting detour into the built in @property decorator in python, and how decorators work in general.

ChatGPT suggested I use the @property tag, and Twitch chat asked me to learn more about it. In the beginning, it really hurt my head, lol, but in the end, I think I got the gist of it XD

Below is the context in which I used the decorator:

```class Post(models.Model):
title = models.CharField(max_length=100)
tldr = models.CharField(max_length=300)
author = models.ForeignKey(User, on_delete=models.CASCADE)
slug = models.SlugField(max_length=250, null=True, blank=True)
body = MarkdownxField(blank=True, null=True)
published_at = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)

@property  # This is a decorator that allows us to call this method as an attribute aka "managed attribute"
def formatted_markdown(self):
    return markdownify(self.body)```

tio.run example of python decorators and how they work

Update      Go Back


Pressing this button removes the post and it can't be undone: Delete

A quote from someone that was funny - Author

Tarot Reader:

Name
Number of cards:
Add question
Hi , you got:
See Vods