This project is a Django web application that allows users to search for weather forecasts by city and provides autocomplete suggestions. It also tracks search history.
- City Weather Forecast: Get weather forecasts for any city.
- Autocomplete Search: Auto-suggest city names as you type.
- Search History: View and access previously searched cities.
- API Integration: Uses OpenWeatherMap and Open-Meteo API for weather data.
- Python 3.8 or higher
- Django 4.x
- Requests 2.28.0
- Django Widget Tweaks 1.4.12
- Django Debug Toolbar 4.0.0
-
Clone the Repository
git clone https://github.com/yourusername/yourprojectname.git cd yourprojectname -
Create a Virtual Environment
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`-
Install Dependencies
pip install -r requirements.txt
-
Apply Migrations
python manage.py migrate- Run the App
python manage.py runserver- Endpoint:
GET api/city-autocomplete/ - Description: Retrieve a list of city names and details matching the search term for autocomplete suggestions.
- Parameters:
term(string): The term to search for city names. Example:London.
- Endpoint:
POST /api/weather/ - Description: Weather forecast details for the specified city.
- Parameters:
- city (string) - The name of the city for which to get the weather forecast.
- Django - The web framework used.
- OpenWeatherMap - Provides weather data.
- Open-Meteo - Provides all cities data.
- jQuery UI - Used for autocomplete functionality.