A simple weather application built with Django that allows users to check current weather conditions for any city.
- View current weather conditions including temperature, humidity, and weather description.
- Search for weather by city name.
- Responsive design for desktop and mobile devices.
- Django
- Python
- OpenWeatherMap API (or any other weather API of your choice)
- HTML/CSS for frontend
-
Clone the repository:
git clone https://github.com/yourusername/weather-app.git cd weather-app
-
Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up your environment variables:
Create a
.env
file in the root directory and add your OpenWeatherMap API key:WEATHER_API_KEY=your_api_key_here
-
Run migrations to set up the database:
python manage.py migrate
-
Create a superuser (optional for admin access):
python manage.py createsuperuser
-
Start the development server:
python manage.py runserver
You can now access the app at
http://127.0.0.1:8000/
.
- Open the app in your web browser.
- Enter the city name in the search bar and submit.
- View the current weather details displayed on the page.
- This app uses the OpenWeatherMap API to fetch weather data.
- Update
weather/views.py
with your API key and endpoint details.
List of dependencies is included in requirements.txt
:
Django>=3.0,<4.0
requests
python-dotenv