Personal Website on Django, Heroku, and AWS S3

I've taken a break from the Kaggle Courses to build my personal website. Over a year ago, I wanted to create an API for a fun idea I had. I learned Django in order to use the django REST framework, but I never put anything into production after some distractions took up my free time. I find frameworks fall in the category of "use it or lose it" type knowledge, and after taking a break I lost the motivation to relearn Django and get my API into production.

In order to create a project portfolio, I decided to relearn the basics of Django in order to create a personal website. Django has a lot of documentation and lets you create a fully functional web app using just Python and HTML. My goal in creating my own website is to host my resume, host personal projects/put my work into production, and host my blog.

Django for Web Development

I watched the lecture of the first 3 courses for Django for Everybody on Coursera after learning of the course on Twitter. This course is fantastic. The instructor ( Dr. Chuck Severance ) thinks that it is important to understand the fundamentals and how something is built, prior to using it. The course teaches the basics of how the internet and HTTPS works. It also covers some python, HTML, and CSS basics. Dr. Chuck then recreates Django models, views, and templates in order to help the learner understand how the Django framework works.

Building

I utilized knowledge that I have previously learned on various youtube tutorials in order to add bootstrap, the Lux theme from bootswatch, and the header component from the Clean Blog bootstrap theme.

I created a couple of static pages for the home page and the about page. I next created a Django model for blog posts. I wanted to be able to easily create formatted blog posts in order to add headers and images, etc, instead of writing HTML for every blog post. I decided I wanted to use Markdown and render that in the Django template. I decided to use Markdown because it seems to be used in many other places, and it will allow me to copy/paste the plain text from my hashnode blogs directly into my personal blog instead of calling the Hashnode GraphQL API. I found the django-mdeditor plugin, and created the model field to be a MDTextField. This plugin allows you to create a Markdown field in Django admin and implement a markdown toolbar, and it also provides a live rendering of the markdown directly in the Django admin activity. I also had to render the Markdown and implemented a custom filter using this tutorial and the markdown python library.

Work From Anywhere

Instead of writing the text for the two static pages as HTML, I decided to create a model in order to render a Django object. I did this so that if I need to update the content, I can sign in to my site from anywhere and update it through Django admin rather than committing changes to the code. I then created a page to host my resume and used a basic Django file field. This worked great, and displayed the pdf in a simple pdf viewer.

Production is a Go

I then followed the docs in Heroku, and after some hiccups, I was able to get my site live and into production. After testing the different pages...

ohfudge.gif

My pdf resume displayed a 404 not found for the media file. After searching on stack overflow, I learned that Heroku cannot store media files due to Heroku's use of dynos. I set up an AWS account, and took bits and pieces from several different tutorials on setting up AWS S3 and Django, as some of the tutorials didn't match the current AWS interface and/or did not cover everything I needed. I created an IAM user account and S3 bucket, configured the settings, and applied them to my Django project.

And poof... all done! My site is now live at johnshearin.com on Heroku's free hosting (so it may take a minute to initially load).

Next Steps

I will start building out some of my personal projects and launching them into production. I still have most of the code from my API that I created last year. I have a program that will be extracting a specific set of text data, running sentiment analysis, and then dumping the statistics into a database. The REST API will then display the raw data, and I will also be using some data visualization and graphing to track the data over time.