Exercise - Set up the starter project
In this module, we'll work on a website for dog shelters. This project focuses on collecting information on all existing dog shelters and the dogs they hope to place across the United States. The fictional hope for this app is that dogs could find suitable homes faster because they would have individuals looking to adopt them from around the United States and not just their local area.
Django is the perfect framework for this project. It provides a route for quickly developing a customer-facing app. Django also provides an established database and admin function that could easily be accessed by employees for quick updating. We've created the initial setup for this project, which allows us to focus on the concepts for this module.
Requirements
You'll need the following resources installed on your computer to complete the exercises:
- Python
- Git
- A code editor such as Visual Studio Code
Clone the starter repository
Open a command or terminal window.
Run the following commands to clone the starter repository and change directory to the project.
git clone https://github.com/MicrosoftDocs/ms-learn-django-generic-views.git cd ms-learn-django-generic-views/starter
Note
The solution for the exercises can be found in the solution directory.
Open the project in Visual Studio Code
We'll use Visual Studio Code as our code editor.
In the same command or terminal window, enter the following command to open the folder in Visual Studio Code.
code .
Create the virtual environment
We'll follow the best practice of working with virtual environments for our project.
Inside Visual Studio Code, open the terminal window by selecting View > terminal.
In the new terminal window, run the following commands to create and activate a virtual environment.
# Windows py -3 -m venv venv .\\venv\\Scripts\\activate # macOS or Linux python3 -m venv venv source ./venv/bin/activate
Install Django
The starter project uses a requirements.txt file to contain the list of all necessary packages. We can install them by using pip
.
In the same terminal window, run the following command to install the required packages.
pip install -r requirements.txt
Start the server
Django can host the application locally. We'll do this step by using the built-in terminal window in Visual Studio Code.
Enter the following command in the same terminal window.
python manage.py runserver