July 21, 2015

Django Girls Workshop Recap


I was invited to a Django Girls workshop over the weekend where I deployed my first Django powered website! It was quite fun. The organizers used GitBook for their Django Girls workshop tutorial. I was delighted to participate because I tried to follow the Django Girls tutorial before on my own but got stuck. It was great to be able to get help and ask “experts” or experienced volunteers there.

It was also interesting to see which parts of the documentation people got stuck on like this line: “We need to pass an instance of User model as an author.” Nowhere in the docs does it explain what they mean by “instance.” I asked a volunteer to explain it to me and we ended up drawing diagrams back and forth.

I enjoyed asking questions to deepen my understanding of how Django works. I learned that I like understanding how things work and writing about them as much as building with code. I also learned that I prefer a big picture of how something works before diving into the details. I like asking “why” as much as “how” and seeing how all the different components of a web app work together conceptually.

##Django Quick Reference

I wrote this mostly for myself but I hope it can be helpful to others. These are the most valuable parts of the Django Girl’s beginner tutorial that I will be reusing a lot as I try to build more Django Python sites.

###Virtual Environment (on Mac) Virtual environments let you work on your projects in their own “box” so that you can run programs with different dependencies easier. For example, I might want to run a project that uses an older version of Python and keep it separate from another project that uses the latest version of Python. Working on these projects in their own “box” or virtual environment keeps their dependencies in order.

To create a virtual environment on a Mac type the following:
~/djangogirls$ python3 -m venv myvenv

Note: In this example ~/djangogirls$ is the directory and “myvenv” is the name chosen for this virtual environment. Feel free to choose your own virtual environment name.

To start or activate your virtual environment:
~/djangogirls$ source myvenv/bin/activate

Once activated the virtual environment name you choose should show up in parentheses before your file path like the example below:
(myvenv) ~/djangogirls$

###Install Django

To install Django use pip (a Python package manager) and type the following into your virtual environment:
(myvenv) ~$ pip install django==1.8

###Basic Django Commands To set up a directory and create default files:
django-admin startproject mysite .

Note: The period after the command above is very important and tells Django to install its file in the current directory.

To create a database:
python manage.py migrate

Note: You need to be in a directory that has a manage.py file. Sqlite3 is the default database that you can find set up in the settings.py file.

To start the web server:
python manage.py runserver

###Next Steps

I’ve used the Django workshop setup to help me set up a Python Django website that uses Wagtail as its Content Management System (CMS). Wagtail is a beautiful, free and open source, user-friendly CMS. That’s right open source and user-friendly! I am excited to explore its features more.

What are your next steps? Check out more Django Tutorials Online or explore Django Girls’ expanded tutorials if you’d like to learn more about Django.