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 Windows 10 and Windows 7. They should work just as well on Windows 8 and possibly Windows Vista.
Instead of following the directions in Django Girls Tutorial Installation, follow these setup instructions instead.
-
Download Docker Toolbox. The download link you want is the topmost
.exe
file on the release page. It should have a name likeDockerToolbox-19.03.1.exe
. -
Run the Docker Toolbox installer. Use the default options for each installation step.
-
There should now be a shortcut named Docker Quickstart Terminal on your Desktop. Double-click that. A command prompt will appear and output a bunch of text.
-
If the Docker Quickstart Terminal seems to stop with an error message, try simply closing it and running it again. If that doesn't work, it's possible you'll need to enable something called "Virtualization" on your computer. Ask your coach for help!
-
At several points, you will be prompted to give the Terminal permission to perform various setup tasks the first time you run it.
-
When this setup step has completed, you should see a message similar to this:
docker is configured to use the default machine with IP 192.168.99.100 For help getting started, check the docs at https://docs.docker.com
-
Close the Docker Quickstart Terminal
-
-
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 to setup the project:
cd %TMP% powershell -command "$url='https://raw.githubusercontent.com/gsong/my-first-blog/master/setup.cmd';$dest='setup.cmd';echo `n`n'Downloading. Please wait...';(New-Object System.Net.WebClient).DownloadFile($url, $dest); echo `n`n'Done!'" setup.cmd
-
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 %USERPROFILE%\src\djangogirls
—in other
words, the src\djangogirls
subdirectory in your user 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.
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 %USERPROFILE%\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:
root@app:~/src/djangogirls$
👉 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. To visit the web site hosted by the web server go to the URL displayed when this command is run.
The make runserver
command will otherwise behave exactly as described in the
tutorial.
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 %USERPROFILE%\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.