For many years I’ve built sites using Wordpress as a CMS. I’ve always loved Wordpress because there are so many great features right out of the box, making it easy to develop sites fast. Plus, coming from an SEO background, Wordpress takes care of so many basic SEO best practices and it becomes even more powerful when you add a 3rd party SEO plugin to the mix like Yoast.
So why did I decide to ditch my favorite plug and play CMS in favor of a CMS that I had to build almost from the ground up? One reason – learn Django.
If you haven’t already guessed from the title of this post, I developed this site using Python’s Django framework. Django is something that I had zero experience with until I decided several months back that I would devote myself to learning it.
Before picking up Django, I did have some experience with Flask but from what I’ve read, Django seemed to be the most popular Python framework so I decided to give it a try. After diving into a quick tutorial, I fell in love with Django and I knew I wanted to learn as much about the framework as I possibly could.
To get my feet wet, I started by taking a Udemy course by Nick Walter – "The Ultimate Beginner’s Guide to Django". A huge shout out to Nick for developing a great introduction to Django. If you’re new to the framework, I highly recommend his course as a starting point. He really simplifies things and gets you up and running with a Django web app in hardly any time at all.
After completing that intro to Django, I knew I wanted to deepen my understanding of the framework and the best way I learn is by doing. So, I committed myself to building and deploying a site using the Django framework.
If you have any experience with Django, you’ve probably heard the acronym MVC thrown around quite a bit.
Django follows the MVC design pattern.
M = Model, V = View, C = Controller
Model – The model is essentially the representation of your data. Don’t confuse it as the actual data because it’s not. For example, this site has a “Blog Post” model and there are certain data fields that make up that model such as a publication date, featured image, content body, etc. It’s how the data is organized, not the actual data.
View – In short, this is the user facing element. Sometimes people change MVC for MTV (Model, Template, View) when referring to Django because templates are such an integral part of the framework. Again, this organizes how the data is presented to the user.
Controller – In the MTV acronym, this part of the pattern is referred to as the “View” (sorry I know this is a little confusing). This simply controls how the data from the model is passed into the “View” using MVC or rather “Template” using MTV.
To sum it up, I just focused on the “Model” and the “Controller” aspects of Django first because I knew exactly what I wanted to build, I just didn’t know how I wanted it to look yet.
Next it was time to work on the “View” (aka “Template”). I started by designing the site using Sketch. If you’re unfamiliar with this application and have an interest in design, make sure you check it out.
I have zero patience for tools like Photoshop or AI when it comes to designing web pages. It may just be me but I find those tools to be incredibly non-intuitive even with the simplest tasks.
What I love about Sketch is that it just makes sense. You can pick it up and start creating even if you’ve never used it before. There are some features like “Symbols” which may not be clear right off the bat, but these concepts are easy to pick up and incredibly powerful. Anyway, enough about Sketch.
As I mentioned in my mini bio, my wife and I love to travel. And when we’re on a trip, I always bring my camera along and take pictures. I wanted to make sure that my travel photography was a key component of the site so I needed to design the templates in a way that really emphasized the photography. To me this meant understated UI so that the photography could stand out.
From the color palette to the UI elements, I wanted to focus on simplicity. I decided to go with a neutral white and dark gray colorway so that the template designs wouldn’t clash with the colorful photos.
Here are a couple of my recent travel posts. As you can see, the images are the focal point and give vibrancy to the simple design:
With the UI design complete, it was time to develop the templates.
The awesome thing about Django is that it has a very powerful templating engine. At its most basic, all you have to do is build the static HTML components and add special template variables wherever you want to insert dynamic content. The templating engine starts to get really powerful when you implement template inheritance, utilize built-in template filters and create custom template tags.
This was fairly easy for me to pick up since I already had experience with the almost identical Liquid templating language. I’ve built quite a few sites in Shopify and Liquid happens to be the templating language that was developed specifically for the Shopify platform.
And last but not least, choosing a front-end framework for me was really a no-brainer. I’m very comfortable with Bootstrap and it’s my go to framework whenever I’m doing any front-end development.
Finally, it was time to deploy the site. First, I set up a Ubuntu server at DigitalOcean.
I also created a PostgreSQL database because I heard from various sources that PostgreSQL is a lot better for production environments than the Django default database - SQLite.
After configuring my VPS I pulled the code for my site from the GitHub repository and then installed and configured the application server (I used Gunicorn).
Once all that was done, I just had a make a few more configuration changes and then I deployed my app or rather my site. Easy peasy!
Even though I’ve deployed my first Django web app, my learning has not stopped here. I continue to work through online courses such as the Treehouse track on Django development as well as books like Two Scoops of Django and other resources. I really love working with the Django framework and hope to learn as much as I can through the process.
Leave a comment if you want to chat about Django. I’d love to hear from experienced developers as well as n00bs like me!