Lessons Learned from a Simple Blog App

Introduction:

I am a blogger. And I am also a programmer. So, it is natural for me to think about how exactly the platforms that I use to publish my articles and get my word out function, right? But unfortunately, I don’t get such chances very often. I am swamped with learning new things, in the hope that one day I will be employed as a software developer. So far, this hope has remained exactly that, a hope. But this means that I need to control my magpie urges.

That is, I need to make sure that I am focused on my learning, and I don’t lose track of the things that I am supposed to do. For example, if I am learning Python and Rust, then I need to keep focus on those two languages, and for now, ignore the rest. But when I started to learn Django, I finally had a chance to take a peek under the hood, to understand how exactly the blogging platform functions.

The project:

I made this simple blog, which you can find here on my GitHub, from the book Django for Beginners by Will Vincent. (Review coming soon!) while it won’t teach you how exactly a platform like Hash Node or WordPress functions, it will teach you the basics, and give you an idea of how exactly a blog works.

So, this is the project that I used to learn the things that I am about to elaborate upon in this article.

Creation of the pages:

A blog, much like any other site, is a collection consisting of various pages. These pages can be created over time, according to the need of the site. However, the interaction of these web pages is an important part of web development. Such as redirecting someone to a page once they take a certain action.

For example, once someone has logged in, they must be redirected to the home page. Once they have written and published the post, they should be redirected to the page of that post. For me, it was a new thing, since I’ve only worked with static HTML with some JavaScript added in for the good measure until now.

Speaking of redirections, the project that I’ve linked above has a bug: When a new user creates their account by signing up, they should be redirected to either their profile page or to the home page. But currently, there is no such functionality. As a result, when you sign up, you get an error. Though the user is created successfully.

Doing things from the admin panel:

Most of us don’t get to see this side of a website. This is where the person who is the owner of the site can control things, such as adding or removing content, moderation, or any other task that might come up in the day-to-day operation of a website.

Initially, when I created this blog, the only way to add posts was through the admin panel. It was only later, as the book showed me how to add other pages such as login, that I was able to add content to the blog from outside of the admin panel.

Still, I appreciate getting a look at this side of the website as well.

Database:

To save the content of your blog, you will need a database. For this project, SQLite was used, since it was readily available, and things were not that complicated that I may need to use some other database. Again, leaving aside my poorly done projects for the Java class in 2020, I haven’t done any projects where I had to use a database. Until now.

Thankfully, I had some knowledge of SQL, so the concepts didn’t bother me that much. I was able to get them very easily. Not that running direct SQL was required for this project. Everything was under the hood, but you still need to know these things, to understand what you are doing.

The final project in the book uses Postgres, so currently I am on a side quest to learn that one. I only know SQLite currently and had a brief encounter with MySQL in 2020. So, this would be the first advanced database system that I will learn properly. Once I am done with it, I will complete the final project of the book, right the review, and publish it here. until then, stay tuned!

Multiple lines of error:

Unlike someone who has an instructor, I am doing these projects on my own. that means when I cause bugs, I have to fix them on my own. and that means reading the large backtraces given to me by Python.

At first, I was balking at such long error messages. It was also difficult to track the problem down, because the control keeps jumping from one file to another, and a lot of these files I have not even written. They come with the Python and Django installation.

But slowly, I learned to pay attention to the files that I have written and ignore the ones that I haven’t even touched on. This means that sometimes I had to read the long error messages line by line, but that is the only way to track the problem down and fix it.

My screen reader also has a problem in that by default, you can only read up to certain lines on the command line before you switch the settings that allow you to read the entire command line’s output from beginning to end. So, this constant switching back and forth was also challenging. I think I should speak with an experienced blind developer, and ask them how they deal with such problems, because I suspect that a company wouldn’t like it if I am reading an error line by line. Not that they like me enough to hire me… ahem.

At least it is all command line. I don’t want to imagine how some IDE would have caused problems for me. I did this project using Visual Studio Code, and that text editor is a godsend.

The virtual environment:

If I’m being honest, I did not have any idea about this, that you can create a virtual environment using Python, and work on your project inside of this environment. This is a good thing because I am slowly learning that this is a practice that is followed in Python land. Even Anaconda does this in Machine Learning projects, where you have to create an environment before you can start working on your project.

(Though to be honest, Anaconda is slow as hell, and it is often stuck at solving environment variables. I feel it is just like me with a difficult math problem.)

Having said that, all of this relies upon ready internet access. Because once you have created your environment, you have to install things on it using pip. I searched around for what kind of solutions people have come up with for solving this issue, and apparently, they host the dependencies on their machines. The rest of it went over my head. I’ll write about it once I have done that practically.

Security:

Let’s be honest. this project is not secure, but still, I still learned some consideration about it. This is mostly regarding Cross-Site Request Forgery (CSRF). This came up during the handling of forms and authentication.

Essentially, wherever you have forms in the application, you must make sure that this sort of request exploit cannot happen. I will never see the HTML form with the same trust again.

Styling:

To be honest, I ignored styling. The book does go into CSS, and how to use it to style the blog, but I decided not to implement it. not because I am lazy, but because I am blind.

Even still, it is not like that I could not copy the CSS, and put it in my project. But the problem is, that HTML and CSS don’t report anything when they bug out. and visually speaking, I would not be able to evaluate the results. So, I ignored this part. Honestly speaking, it doesn’t matter to me. because no sane company will let me work on CSS and other styling-related elements, due to my blindness. So, ignoring it has no impact as far as I am concerned.

Final learning, how easy it was to create a blog:

With a few lines of code, I created a blog. Not necessarily a feature-full application, not the best looking one either, but a functioning blog. Having said that, it is a good thing that I learned HTML long before I started with such projects. Because otherwise, I would have been hopelessly lost. I believe that you should start with simple things in tech, and then work up, and as I start to learn more and more complicated things, that belief has been confirmed over and over.

So yes, this is the knowledge I have walked away with after doing a simple blog project in Django. I do hope that I will continue to learn, and do more such projects come next year. not only they are important to show off to a potential employer, but they also boost my confidence. And they also give me an excuse to write such articles!

I also write on my other blog, which you can find here, and I also have a web serial novel, that you can read here. Until next time,

-Tanish.

Did you find this article valuable?

Support Tanish Shrivastava by becoming a sponsor. Any amount is appreciated!