Skip to content
/ my-first-blog Public template

A Docker based starter template for the Django Girls tutorial

License

Notifications You must be signed in to change notification settings

gsong/my-first-blog

Repository files navigation

Docker Based Django Girls Tutorial Starter

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.

Installation

Instead of following the directions in Django Girls Tutorial Installation, follow these setup instructions instead.

  1. 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.

  2. 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.

  3. 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.

  4. 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").

  5. 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
  6. Install a code editor.

    Here's a list of editors to consider. All of them will work for macOS, Linux, or Windows. In order of biased preference:

  7. Create a PythonAnywhere account.

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.

Additional Notes for Ubuntu

  • 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) to disco. 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 without sudo.
  • Make sure to also install docker-compose before running make cli.

Changes From the Tutorial

Command Line Operations

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.

Command Line

👉 Whenever you see mention of "open up a command line":

  1. Open up a CLI window

  2. Navigate to the project directory

    cd ${HOME}/src/djangogirls
  3. 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.

Run Django Web Server

👉 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.

Skip the Following Sections

Since we're simplifying the installation process, you can skip (completely or mostly) the following sections:

Minor Changes

Instead of setting:

ALLOWED_HOSTS = ['127.0.0.1', '<your_username>.pythonanywhere.com']

Set it to:

ALLOWED_HOSTS = ['*']

Hints on Window Management

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:

  1. Command line interface console
  2. Browser
  3. Editor

CLI Console (aka Terminal)

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.

Browser

Use two separate windows to manage all the pages.

Window #1

Lay out your first window with the following tabs, in order:

Keep this window persistent and consistent throughout your day.

Window #2

Use this window for any research you need to do.

Editor

Make sure your editor is rooted to ${HOME}/src/djangogirls for convenience. Each editor will have its own way of accomplishing this.

Enhancements

IPython

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.

Autocompletion

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

Command History

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.

About

A Docker based starter template for the Django Girls tutorial

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published