Adventures in Django, Part 1: Intro and Installation

This is a multi-part series covering a product person’s attempts at learning the Django web framework, in Windows, armed only with an entry-level understanding of Python, some intermediate SQL, and some okay general development knowledge.


What are you doing?

As part of my effort to develop my technical skills in my spare time, I decided to take a look at the Django Web framework and get my feet wet by diving in and building a simple app a friend requested. I’ve always found that I learn best through actually working with tools, as opposed to just reading about them. Fortunately, the folks at Django have created a really excellent introductory tutorial that does a good job of both holding your hand and explaining the why behind key concepts (this is where a lot of tutorials fail, I’ve noticed).

Why start with Django?

There’s a post I like which offers a roadmap to becoming a web developer in 2017, and it doubles as a nice platter of options for people who want to stay on top of relevant technical skills. The Python/Django combo was both one of the choices on the chart that caught my eye and was something I’ve had several developer friends recommend to me. It was basically this or Ruby-on-Rails again if I wanted to learn more about back-end development.

I’ve been wanting to do some more work with Python anyway, and Django presents an easy option to make something quickly while doing that. I figured actually getting an app running would also get me more familiar with data structures, ops, and storage (Postgres and AWS or Heroku), since I actually need to store some app data and host it all when I’m done.

Easy Breezy Installation

First up was actually getting Django installed. The installation was a breeze with Python 3.6 and pip, and I’d fortunately already had my virtualenv set up from going through a Heroku tutorial. I also installed psycopg2 in anticipation of the next step. If that all sounds sounds like gibberish to you, just follow that first link link and do everything it tells you to, while reading the explanations at each step. It’s really easy if you’re comfortable with the command line and Python.

Not comfortable with the command line or don’t know much about Python? No sweat! This free book is a great starter reference, and I also picked up a fair bit of good Python information early on at sites like Codecademy, which is a good place to practice.

With that out of the way, I moved on to the next part of my setup: Getting my database installed so I had somewhere to store all this data I’d be working with.

Databases: Not Quite So Breezy

If you’re doing something simple, you can usually just use the SQLite database that comes with Django, but why do something simple when you can do something the hard way and learn more in the process? Serious projects won’t use SQLite (so they tell me), so instead I downloaded the installer for PostgreSQL.

I wasn’t able to find good documentation for using Postgres as easily as Django, so it took some trial and error (and Googling) to do the necessary things like setting up an admin user with database creation privileges and creating a database for my project, both of which had to be done via command line within Postgres. It was worse since I’m obstinately developing in Windows. The cool kids are all using Macs or Linux, so that’s what gets the most coverage in online tutorials.

This guide was really helpful if you start at the part where you run Postgres from the command line with “psql”. It’s easiest to do this if you add the Postgres bin directory to your Windows PATH environment variable, which allows you to easily run that from the command line whenever you want. If, like me, you’d never worked with PATH variables before this, this is a fantastic post about both what they are and how you go about adding them.

After logging in to my newly minted database to confirm everything was working correctly, I was ready to start building a Django app!

Thanks for reading! Join me soon for Part 2, where I actually begin making stuff and not just installing tools and talking about making stuff.

Tabula Rasa

Time for something new. I’m still working on a number of personal projects (including my writing), but I wanted a fresh start on the blog. Simpler, cleaner. Tighter.

The content of the posts here will change slightly: In addition to writing about writing, I’ll be posting about all my interests — what I’m reading, what I’m working on, what I’m thinking about.

We’ll see how that shapes up. Thanks for coming along for the ride.