Django Courses

Demo and Exercise Files

To get started, create a new folder named Webucator on your computer wherever you want, but make sure you remember where it is. Then, download the demo and exercise files that you will use throughout these lessons and unzip them into the Webucator folder you created.

This will create a ClassFiles folder in the Webucator folder. Rename the ClassFiles folder Django.

The structure should look like this:

  • Webucator
    • Django
      • projects – This folder just contains a placeholder file. You will create some Django projects within it.
      • solutions – This folder contains completed code for each lesson. When you finish a lesson, you can compare your code with the code found here.
      • starter-code – We will often reference files in this directory. In most cases, this will be to save you typing out long pieces of code. These references will usually be in footnotes, so be on the watch for them.

Visual Studio Code

We use Visual Studio Code for Django development and we recommend that you do too, at least while working through these lessons, as it will make it easier for you to follow along with the many demos and exercises.

  1. Visit https://code.visualstudio.com and download Visual Studio Code for your operating system.
  2. Install Visual Studio Code:
    1. Windows instructions: https://code.visualstudio.com/docs/setup/windows
    2. Mac instructions: https://code.visualstudio.com/docs/setup/mac
    3. Linux instructions: https://code.visualstudio.com/docs/setup/linux
  3. Create a folder somewhere on your computer for storing Visual Studio Code workspaces. Name the folder vs-code-workspaces or something similar.
  4. Open Visual Studio Code.
  5. From the File menu, select Save Workspace As… VS Code: Save Workspace As...
  6. Save the workspace as webucator-django within the workspaces folder you created earlier: VS Code: Save Workspace As Webucator
  7. If Visual Studio Code’s Explorer panel isn’t open, open it by clicking the files icon in the upper left. Then click the Add Folder button: VS Code: Add Folder
  8. Select the Django folder (the one you renamed from ClassFiles) and click Add: VS Code: Add Django Folder
  9. You will now see the Django folder in Visual Studio Code’s Explorer panel: VS Code: Django Folder

The Python Extension

Visual Studio Code has many freely available extensions for different programming languages. Python developers should install Microsoft’s Python extension. As shown in the screenshot that follows:

  1. Click the Extensions icon (below the bug) on the left of the Explorer panel.
  2. Search for “Python”.
  3. If it doesn’t show that the extension is already installed, click the Install button.

VS Code: Install Python Extension

Visual Studio Code Color Themes

You can customize the Visual Studio Code color theme by selecting File > Preferences > Color Theme. The default is a dark theme. We use a light theme for our screenshots.

Running Python

Python runs on Microsoft Windows, Mac OS X, Linux, and other Unix-like systems. The first thing to do is to make sure you have a recent version of Python installed:

  1. Open the terminal in Visual Studio Code by pressing Ctrl+` or selecting New Terminal from the Terminal menu.
  2. Run python -V:
    …/Webucator/Django> python -V
        Python 3.8.5

If you have Python 3.7 or later, you are all set, though we recommend you get the latest version, which is 3.8.5 at the time of this writing.

You can download Python for free at https://www.python.org/downloads/. After running through the installer, run python -V in the terminal again to make sure Python installed correctly.

Your Mac will likely have a version of Python 2 already installed. After you install Python 3, you may find that running python -V still shows the Python 2 version. In that case, try running python3 -V. That should output the version of Python 3 that you have. If it does, then you should use the python3 command instead of the python command to run Python 3.

If you would prefer to be able to use the python command for Python 3 (and who wouldn’t), visit https://www.webucator.com/blog/2020/02/mapping-python-to-python-3-on-your-mac/ to see how you can map python to python3.