Here's a comprehensive README.md for your weather app that explains how it works and how to set it up:
A modern Django web application that allows users to compare weather conditions and forecasts between two cities using OpenWeatherMap API.
- Compare weather data between two cities side-by-side
- Display current weather conditions (temperature, description, icon)
- Show 5-day forecast for each selected city
- Modern, responsive dark-themed UI
- Clean visualization of weather data
- Python 3.10+
- Django 5.1.6
- OpenWeatherMap API
- HTML5/CSS3
- Python 3.10 or higher
- OpenWeatherMap API key (sign up at openweathermap.org)
-
Clone the repository:
git clone https://github.com/yourusername/Weather-app.git cd Weather-app -
Create and activate a virtual environment:
# On Windows python -m venv WeatherApp WeatherApp\Scripts\activate # On macOS/Linux python -m venv WeatherApp source WeatherApp/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the project root:WEATHER_API=your_openweathermap_api_key_here HISTORY_API=your_openweathermap_history_api_key_here -
Navigate to the Django project:
cd WeatherApp/WeatherMain -
Run migrations:
python manage.py migrate
-
Run the development server:
python manage.py runserver
-
Open your browser and navigate to:
http://127.0.0.1:8000/
- Enter the name of the first city in the "Enter first city..." field
- Optionally, enter a second city for comparison
- Click the "Compare" button
- View the current weather and 5-day forecast for both cities side-by-side
Weather-app/
├── WeatherApp/ # Virtual environment
├── WeatherMain/ # Django project
│ ├── WeatherMain/ # Main project configuration
│ │ ├── __init__.py
│ │ ├── asgi.py
│ │ ├── settings.py # Django settings
│ │ ├── urls.py # URL configuration
│ │ └── wsgi.py
│ └── main/ # Main Django app
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py # App URL configuration
│ ├── views.py # View functions
│ └── templates/ # HTML templates
│ └── main/
│ ├── index.html # Main comparison page
│ └── city.html # City weather template
└── .env # Environment variables (API keys)
This app uses the following OpenWeatherMap API endpoints:
- Current weather data:
https://pro.openweathermap.org/data/2.5/weather?q={city}&appid={api_key} - Historical data:
https://history.openweathermap.org/data/2.5/history/city?lat={lat}&lon={lon}&appid={api_key}
- If you encounter a
TemplateDoesNotExisterror, make sure themain/templates/main/directory structure is correctly set up. - If you see API key errors, verify your keys in the
.envfile and check if they're properly loaded in the application. - For any other issues, check the Django development server logs for detailed error messages.
- Add user accounts to save favorite cities
- Implement more detailed weather information
- Add graphs for temperature trends
- Include air quality data
- Add weather alerts and notifications
This project is licensed under the MIT License - see the LICENSE file for details.
