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:
- 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.
- Visit https://code.visualstudio.com and download Visual Studio Code for your operating system.
- Install Visual Studio Code:
- Create a folder somewhere on your computer for storing Visual Studio Code workspaces. Name the folder vs-code-workspaces or something similar.
- Open Visual Studio Code.
- From the File menu, select Save Workspace As…
- Save the workspace as webucator-django within the workspaces folder you created earlier:
- 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:
- Select the Django folder (the one you renamed from ClassFiles) and click Add:
- You will now see the Django folder in Visual Studio Code’s Explorer panel:
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:
- Click the Extensions icon (below the bug) on the left of the Explorer panel.
- Search for “Python”.
- If it doesn’t show that the extension is already installed, click the Install button.
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.
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:
- Open the terminal in Visual Studio Code by pressing Ctrl+` or selecting New Terminal from the Terminal menu.
…/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