A Django-based weather information application that fetches weather data from OpenWeather API.
- Clone the repository
git clone <repository-url>
cd weather-project
- Create a virtual environment and activate it
python -m venv venv
# On Windows
venv\Scripts\activate
# On Unix or MacOS
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Create a .env file in the project root with the following variables:
OPENWEATHER_API_KEY=your_api_key_here
DJANGO_SECRET_KEY=your_django_secret_key_here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
- Run migrations
python manage.py migrate
To get weather information for a city:
python manage.py getweather "city name" [--units metric|imperial]
Examples:
# Get weather in Celsius (default)
python manage.py getweather "London"
# Get weather in Fahrenheit
python manage.py getweather "New York" --units imperial
Features:
- Temperature in both Celsius (metric) and Fahrenheit (imperial)
- Feels-like temperature
- Humidity percentage
- Weather conditions
- Wind speed (m/s for metric, mph for imperial)
- Response caching (10-minute cache to avoid repeated API calls)
- Input validation for city names
- Detailed error messages
- Never commit the .env file to version control
- Keep your API keys and secret keys secure
- In production, set DEBUG=False and configure ALLOWED_HOSTS appropriately