I made a few updates to the site, mostly focusing on updating the home page sidebar to have some actual information. The old side bar was just place holder text from the tutorial I found, but the new side bar is populated with the last (3) comments made on the blog.
Before I dig into the coding to make this happen, I want to make a small aside that my old desktop died that was used to make this site and I have moved onto a new laptop which I have been enjoying. I was bit freaked out when I lost the old desktop due to my poor IT backup practices. I deploy this site using git, but should move the site to github. I need to git this done, it looks like Heroku (the site I deploy to) can accommodate both git and github.
The process to get the website back up and running on the new machine was pretty easy. Luckily, my SSD in the old desktop was not fried and I was able to copy all of the website files off of the SSD and xfer onto the new computer. I was able to copy all of my environment variables off of the heroku machine and paste them into the computer. After some struggling to get the local variables set up, I was able to begin working on the site again.
Live Comment Feed
For awhile I wanted to pull a few of the recent comments on the site and have them populate the sidebar like most modern blog sites. Given the popularity of chat gpt, I figured I would give it a go to see if could maybe point me in the right direction.
ChatGPT - Did it Work?
Not really. Here is an example of how the interaction I had with chatgpt:
The code that it spat out was correct, but I did not give it enough guidance to properly make this code usable for my specific project. The code produced by chatgpt will extract comments from the database, but this will not in a useable format for rendering into HTML.
Given that I have not played with Django (package to make the website) in awhile, I forgot a lot of the basics. Once you have retrieved the data you want to be in the webpage, you need to pass this data to a view. This was the part that chatgpt missed and that I had forgotten. After some struggling, I was able to pass this data into my views.py file.
Setting up get_context_data enables me to pass both post and comment database information into the home.html file.
With a little tweaking to the html file:
the comments will render in and you get a new linked comment you can click on.
A nice update.
Next item to tackle, allowing users to update their comments.
If you make a comment and you are the user that made the comment you should see an "Update" button next to your comment now.
The code to make this was pretty easy and I am starting to feel more comfortable working django.
Urls, Views and html:
In addition, I added a google tag to the concrete design tool on the site. For the longest time, I thought no one visited this portion of the site, which is probably true, but reviewing the analytics on the site revealed that actually no one had ever visited the site. I realized that I forgot to add a tag to that page. I hope to come back to the concrete design tool soon and document it, I think it is a powerful tool that someone might find useful