A user first signs up and or logs in using their email. Then they can enter city name to create a list of weather data for each city entered. The user can then click on any of cities in the list do display a more detailed view of the weather in that city. The more detailed view gives the weather for the next two days in 3hr increments with each increments color corresponding to the temperature for that time period.
I created this project purely as a learning experience. Here is a list of some of the things I became familiar with along the way.
- How Django works and how a Django project is structured.
- How APIs work and how to get data from them and present them to the user.
- Using Bootstrap5 classes
- User authentication in Django
- Email validation with SendGrid
- Forms in Django with Crispy Forms
git clone <repository_url>
Once inside the project folder, create a virtual environment.
python3 -m venv .venv
source .venv/bin/activate
With the virtual environment active, install the project dependencies listed in the requirements.txt file:
pip install -r requirements.txt
Create a file in the root directory of the project named .env. Add the following lines to the file.In the file add your Django SECRET_KEY that you are going to need to generate. You are also going to need an api key from OpenWeatherAPI.
Remember to gitignore this file before ever pushing it to a remote repo.
DEBUG=True
SECRET_KEY=<your_secret_key>
API_KEY=<your_open_weather_api_key>
Run database migrations to set up the database schema for the project. Django migrations handle the creation of database tables and other necessary structures:
python manage.py migrate
After running this command, a Django-supported SQLite3 file will be created. This file will serve as your custom database.
The superuser has access to the Django admin panel. Here you can manage the users and data.
python manage.py createsuperuser
Finally, start the Django development server. This command launches the project locally, allowing you to explore its features in your web browser.
python manage.py runserver
Open your web browser and go to http://localhost:8000/ to see the Django project.
If you created a superuser, access the admin interface at http://localhost:8000/admin/.