In order to simplify the setup for Django Girls workshops, let's use Docker to set up most of our development environment.
Caveat: These instructions have been tested thoroughly on macOS, and should work just as well on most Linux based systems.
Windows users should refer to the Windows README.
Instead of following the directions in Django Girls Tutorial Installation, follow these setup instructions instead.
-
Install Docker—follow the instructions for your specific operating system. If installing on Ubuntu, you can use the install-docker-ubuntu.sh script included in this repository, or see Additional Notes for Ubuntu section below.
-
Sign up for a free GitHub account, if you don't have one already. If you do have an account, make sure you can login with your username and password.
-
Make a copy of this repo into your own account by forking this repo. To do this, click on the "Fork" button at the top of this page.
-
Take a little time to read through "Introduction to the command-line interface", so you can be familiar with how to use your command line interface ("CLI").
-
Open a CLI window (also known as terminal) to setup the project:
cd /tmp curl -OL https://cdn.jsdelivr.net/gh/gsong/my-first-blog/setup.sh source setup.sh
-
Here's a list of editors to consider. All of them will work for macOS, Linux, or Windows. In order of biased preference:
- Visual Studio Code from Microsoft, free.
- Atom from GitHub, free.
- Sublime Text, $80.
These steps will set up your project in ${HOME}/src/djangogirls
—in other
words, the src/djangogirls
subdirectory in your home directory.
🎉 You're ready to start the tutorial! Continue with How the Internet works. Note some minor changes you'll have to keep in mind as you follow the tutorial.
- If you're installing Docker on Ubuntu 19.10 Eoan, in the command to add the
Docker repository to your system, change
$(lsb_release -cs)
todisco
. This is because Docker does not have official repositories for Eoan yet, so we use the repository for the previous version (Disco). - Make sure to follow the
Manage Docker as a non-root user
steps in Post installation for Linux instructions, so that you can run docker withoutsudo
. - Make sure to also install docker-compose before running
make cli
.
You'll be using Docker containers throughout the tutorial to do your work. It's best to keep two CLI windows open at the same time: one to run the command line, and another to run your web server.
👉 Whenever you see mention of "open up a command line":
-
Open up a CLI window
-
Navigate to the project directory
cd ${HOME}/src/djangogirls
-
Start an interactive container:
make cli
There's no need to activate a virtual environment, since our Docker container is our virtual environment.
Instead of the prompt you see in the tutorial instructions:
(myvenv) ~/djangogirls$
You'll instead see:
${YOUR_USERNAME}@app:~/src/djangogirls$
You can leave the Docker container by entering the command exit
.
👉 Whenever you see mention of python manage.py runserver
, use the following
instead:
make runserver
This will start the Django web server in a container, and will behave exactly as described in the tutorial.
If you get an error message, make sure that you're not still in the docker
container after running make cli
. If you are, you can either open a new
command line tab to run make runserver
in, or first exit make cli
with
exit
.
Since we're simplifying the installation process, you can skip (completely or mostly) the following sections:
-
Python installation (skip completely)
-
Django installation (skip completely)
-
-
Installing Git (skip completely)
-
Starting our Git repository (skip partially)
Most of this section can be skipped, except at the very end where we save our changes:
git add --all . git commit -m "My Django Girls app, first commit"
-
Pushing your code to GitHub (skip partially)
Since we've already cloned from a repo, we can skip most of the steps here. The only thing we need to do is:
git push
Continue following everything as-is from Setting up our blog on PythonAnywhere.
-
Instead of setting:
ALLOWED_HOSTS = ['127.0.0.1', '<your_username>.pythonanywhere.com']
Set it to:
ALLOWED_HOSTS = ['*']
During the course of the tutorial, you'll need to juggle lots of different windows. This is one suggested way to arrange the different windows on your screen. You should have three applications running:
- Command line interface console
- Browser
- Editor
You should have two windows or tabs for working with the command line. Keep one dedicated for typing and running commands, and another one for running the Django web server, which you'll rarely need to touch.
If you use two windows, it's easier if you stack them top and bottom.
Use two separate windows to manage all the pages.
Lay out your first window with the following tabs, in order:
- Django Girls Tutorial
- Local blog
- Local admin
- PythonAnywhere bash console
- PythonAnywhere "Web" section
- PythonAnywhere hosted blog
- PythonAnywhere hosted admin
Keep this window persistent and consistent throughout your day.
Use this window for any research you need to do.
Make sure your editor is rooted to ${HOME}/src/djangogirls
for convenience.
Each editor will have its own way of accomplishing this.
Instead of the plain Python console, we've installed IPython, which is much
more powerful. To use it, just type ipython
in place of python
or python3
.
Since CLI commands are sometimes complex and prone to typos, we use
autocompletion to help us with the task. To use autocomplete, simply press the
TAB
key, and your computer will make suggestions.
The Docker image has the following autocompletion installed for your convenience:
- bash: Unix commands, path names
- Django: management commands (i.e.
python manage.py …
) - IPython: Python modules, classes, methods, functions, etc.
- Git:
git
subcommands
Both bash
and ipython
have command history enabled. This means you can use
↑
(up arrow) to access commands you've typed before, even across multiple
sessions.