Some Last Minute Changes
Blog Home

Some Last Minute Changes

June 29, 2019 |  Categories:  Development  

Gahhh, I'm so close to publishing this website but there are still just a few things I want to care of before sending it out for the world to see. The most important of which is probably cleaning up all of my code. Don't get me wrong, it's not in a bad state by any means. But I just need to go through all of my files (especially my HTML templates!) and make sure that everything is concise, pretty, and efficient. Since I've never received any formal training in proper HTML styling, I'm going to do a bit of research tonight to see if I can find a good tutorial. Then I'll just need to comb through each of my HTML templates to make sure they're up to snuff. I don't anticipating it taking too long, but when it comes to programming, it's best not to jinx yourself. I probably just did. Dangit!! At any rate, cleaning up my code is the last objective I have before finally pushing the site to publication. After the work I did today, I'm really happy with how everything has come together. First, I managed to solve the blog/category sorting issue I described in my last post. Each time I clicked on a category link beneath one of my blog posts, I'd get a FieldError from Django. Essentially, this meant that the view function that I was calling each time I clicked the link was running into an error with the query sort I was trying to impost on the collection of all my posts. The objective of the function was to create a new collection of all previous posts tagged under the category of interest and display them on a page identical to my blog index. From there, the user would be able to browse category-specific posts and read them as usual. Much to my chagrin, my origin query sort: posts = Post.objects.filter(categories__name__contains=category).order_by( '-created_on' ) was simply missing additional underscores between 'categories' and 'name' and 'name' and 'contains.' After nearly an hour of fruitless troubleshooting, this simple addition did the trick. From there, I just standardized the formatting for the new 'blog_categories.html' and added a link back to blog index. I then turned my attention to my navbar. To enhance the site's usability, I wanted the navbar to remain fixed at the top of the window regardless of scrolling so that the user could seamlessly hop between pages. The issue however, was that my transparent navbar was sitting on top of the page contents as they scrolled past, producing an illegible and sloppy mess. I wanted to find a way to make the navbar a solid color upon scrolling down, and that's exactly what I found. A fellow programmer by the name of Erin Manahan contributed this brilliant Javascript function to a discussion board where this exact issue was addressed. Their code was as follows: $(document).ready(function() { $(window).scroll(function() { if($(this).scrollTop() > 50) { $('.navbar').addClass('solid'); } else { $('.navbar').removeClass('solid'); } }); }); What this function does is add the new class 'solid' to the existing 'navbar' class once the user scrolls 50 pixels down the page. With this in hand, I was then able to customize the new 'navbar-solid' class in my custom CSS file to conform with the theme of the rest of my site. I'm incredibly grateful to Erin for their elegant and well-explained solution to my dilemma. In the incredibly off chance that you ever read this, thank you Erin!! My latest bit of work for the day was going through my "About Me" section one more time. I only made a few changes, but I feel really confident about it now, and am excited to finally share this site with the rest of the world. -Joe

Leave a comment:



I'm Joe Pickert, and welcome to my blog.

Here, you can find a collection of my thoughts both tech-related and otherwise.

If you find something that interests you, please leave a comment! I'd love to hear your thoughts and feedback!