Learning Django

Published on:
March 20, 2017

I wrote this site in Python using the Django framework. I already covered how I went about learning Python, so now I'm going to do the same thing for how I learned Django. Or maybe I should say “started” learing Django, because I’m just scratching the surface of what Django can do.

So What is Django, Anyway?

When I started looking into Django, I had the following questions at first:

  1. “What is Django?”—Django is a framework for building web applications in Python.
  2. “What is a Framework?”—Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API). Wikipedia
  3. “Say What?”—Frameworks are like a parts bin of code other people wrote so that you don't have to. That way you can get on with building whatever you're making.
  4. “Why Didn't Wikipedia Just Say That?”—Unfortunately, I don't have all the answers.

In summary, Django is a pile of code written by a super smart team of other people that you can customize to fit your web development needs. Django only handles the server-side part of website building. If you read my CS50x review, Django helps with the Model and Controller parts of the MVC, but your views need to be written in HTML/CSS/JS.

Where Do I Start?

One of the best problems we have in the world of the internet is that there are so many free educational resources sometimes it can be hard to chose one. Django is no exception. I decided to go straight to the source and see what was available at www.DjangoProject.com. Luckily for me, right on the home page (right side, halfway down) there’s a link to a tutorial. That link leads straight to the tutorial I used to make my polls app.

As you can see, the app works! As far as I'm concerned, that's a successful tutorial right there. One thing to note is that this tutorial is not oriented at complete programming beginners. The Django tutorial—and all the documentation on the website—assume a good working knowledge of Python, and at least some understanding of Object-Oriented concepts. They also assume that you know however much HTML, CSS, and Javascript you need to build the front-facing part of your website.

If you have those things, I’d give the Official Django Documentation tutorial, and the docs in general, a 10/10. The Django Documentation is the best official documentation of any programming library I’ve used so far. Granted that’s not a huge list, but it’s getting longer every week. The Django docs are still head and shoulders above almost anything else I’ve seen.

Nice Poll. Where’d All The Other Stuff Come From?

The polls tutorial covered pretty much everything I needed to make more complicated applications. It might look simple on the outside, but under the hood that little poll hooks into a relational database that I set up myself. I also have a login-authenticated admin page where I can add questions, choices, and decide when they’re published from anywhere.

After writing all of that, turning what I learned into a blog was mostly a matter of syntax and styling. The only thing in my blog that wasn’t covered in the tutorial was the many-to-many relationship between blog posts and tags. That, and everything else you can think of, is covered pretty well in the Django Documentation.

How Did You Get It On The Web?

Great question imaginary future reader. My website is hosted at Python Anywhere. Python Anywhere offers free hosting for small web-apps written in Python. Because they specialize in Python apps, they have a whole boatload of tools pre-installed that you have to manually set up on other hosting platforms. I’ve used them to host three different websites/apps now and the one time it wasn’t a breeze their tech support was extremely helpful and responsive.

I found Python Anywhere after google led me to another Django tutorial. Django Girls is a non-profit organization that puts on free programming workshops all over the world. From their website:

The goal of the foundation is to advance the education of the public in particular but not exclusively women in the subject of computer science by providing or assisting in the provision of programming workshops and educational material.

Seems like a great goal to me. I’ve referenced the deployment portion of their Django Tutorial for three separate deployments. It’s worked like a charm.

Now What?

That’s the big question, isn’t it? I started this blog as a way to write down my thoughts on some things I’d been working on, and now I’m up to where I am currently. If you have an opinion about what I should write about in the future, take my poll and let me know! Until next time, thanks for reading.