My Personal Blog

Home

Adding Markdown Support to the Blog

Jan. 19, 2024 | Categories: dev

Adding markdown was relatively straightforward thanks to this tutorial. All I had to do was to import the markdown package in the views.py file and convert the post.body to markdown.


import markdown 
# ...
def blog_detail(request, pk):
md = markdown.Markdown(extensions=["fenced_code"])
post = Post.objects.get(pk=pk)
post.body = md.convert(post.body)
# ...

I also had to modify the HTML template to flag the markdown to be rendered as safe:


<p>{{ post.body|safe | linebreaks }}</p>

For some reason the markdown is still pretty ugly, so I'll have to see if this could be fixed by a template.


While the change to the code was relatively simple, I struggled a bit with figuring out what the local development workflow should be. I ran into two issues.



  1. I am using poetry to manage the environment, and for some reason Django was not installed, so I had to reinstall everything with poetry install --no-root. The --no-root was due to the install erroring out when trying to install the project. I'm not sure if that is a problem but it ended up working fine.

  2. When I tried poetry run ./manage.py runserver, I got an error relating to the database. I realized this was due to some changes I had made to the settings.py file for deploying on Render. Notably, this entailed switching away from a SQLite db to postgres. I therefore had to figure out how to get postgres running (I downloaded the mac app, and ran postgres=# CREATE DATABASE personal_blog; to get the db I needed.)


So far this has been decent progress. I am realizing that:


Leave a comment:

Comments:

On Jan. 19, 2024 Adrien wrote:

The linebreaks are massive. Why?

On Feb. 19, 2025 Celesta wrote:

https://jekyll.s3.us-east-005.backblazeb2.com/20241213-1/research/je-tall-sf-marketing-(111).html
Knowing a little bit about what you’d wish to put on might help you narrow down your choices.

On April 23, 2025 Elida wrote:

https://filedn.eu/l46Ju9IQhhQ84ifWoIzEYnJ/digi111sa/research/digi111sa-(466).html
I was very impressed to see that there are classy and elegant outfits for all plus size girls.

On June 13, 2025 Cathleen wrote:

https://storage.googleapis.com/digi153sa/research/digi153sa-(332).html
Her mother, Rita, opted for this champagne-hued gown that was equally as ethereal.

On June 21, 2025 Whitney wrote:

https://filedn.eu/l4uw5uiN1qUR9BCabqOgPER/cz-marketing-111/research/cz-marketing-(404).html
For a seashore marriage ceremony I would put on one thing a bit more flowy like the flowery and ruffly attire above.

On June 23, 2025 Garrett wrote:

https://digi479sa.s3.us-east-005.backblazeb2.com/research/digi479sa-(162).html
Light, sunny, and normally stuffed with flowers, and they often use pastel colors inspired by springtime blooms.

On June 24, 2025 Major wrote:

https://cz-marketing-146.sgp1.digitaloceanspaces.com/research/je-tall-sf-marketing-(294).html
Everyone is conscious of you're the bride, so don't be
concerned about your mother sporting white or a full skirt alongside you.

On June 28, 2025 Brigida wrote:

https://elio191.wordpress.com/2025/06/16/2/
Check out the guide for excellent ideas and ideas, and get ready
to chop a dash at your daughter’s D-day.