Skip to main content

django-owm

PyPI Status Python Version License

Read the documentation at https://django-owm.readthedocs.io/ Tests Codecov

pre-commit Black

django-owm is a reusable Django app for fetching and storing weather data from the OpenWeatherMap One Call 3.0 API. It provides a simple interface for managing weather locations, fetching current, historical, and forecast weather data, and displaying this information in your Django project.

Features

  • Fetch and store weather data from OpenWeatherMap One Call API 3.0
  • Support for current, minutely, hourly, and daily weather data
  • Weather alerts tracking
  • Customizable models for storing weather data
  • Management commands for easy interaction with the app
  • Celery tasks for automated weather data fetching
  • Built-in views and templates for displaying weather information
  • Flexible configuration options

Requirements

  • TODO

Installation

  1. Install the package using pip:
pip install django-owm
  1. Add 'django_owm' to your INSTALLED_APPS setting:
INSTALLED_APPS = [
    ...
    'django_owm',
]

Configuration

Add the following settings to your Django project's settings.py file:

DJANGO_OWM = {
    'OWM_API_KEY': 'your_openweathermap_api_key',
    'OWM_API_RATE_LIMITS': {
        'one_call': {
            'calls_per_minute': 60,
            'calls_per_month': 1000000,
        },
    },
    'OWM_MODEL_MAPPINGS': {
        'WeatherLocation': 'your_app.WeatherLocation',
        'CurrentWeather': 'your_app.CurrentWeather',
        'MinutelyWeather': 'your_app.MinutelyWeather',
        'HourlyWeather': 'your_app.HourlyWeather',
        'DailyWeather': 'your_app.DailyWeather',
        'WeatherAlert': 'your_app.WeatherAlert',
        'WeatherErrorLog': 'your_app.WeatherErrorLog',
        'APICallLog': 'your_app.APICallLog',
    },
    'OWM_BASE_MODEL': models.Model,
    'OWM_USE_BUILTIN_ADMIN': True,
    'OWM_SHOW_MAP': False,
    'OWM_USE_UUID': False,
}

Replace 'your_openweathermap_api_key' with your actual OpenWeatherMap API key, and adjust the model mappings to point to your custom model implementations if you're not using the default models.

See the Usage Reference for more details.

Migrate Database

Run migrations to create the necessary database tables:

python manage.py migrate

Quick Start

  1. Create a new weather location:
python manage.py create_location
  1. Fetch weather data for all locations:
python manage.py manual_weather_fetch
  1. View the weather data in the Django admin interface or use the provided views to display the information in your templates.

Customization

Models

You can customize the models used by django-owm by creating your own models that inherit from the abstract base models provided by the app. Update the OWM_MODEL_MAPPINGS in your settings to use your custom models.

Views and Templates

django-owm provides basic views and templates for displaying weather information. You can override these templates by creating your own templates with the same names in your project's template directory.

Celery Tasks

To set up automated weather data fetching, configure Celery in your project and add the following task to your CELERYBEAT_SCHEDULE:

CELERYBEAT_SCHEDULE = {
    'fetch_weather_data': {
        'task': 'django_owm.tasks.fetch_weather',
        'schedule': crontab(minute='*/30'),  # Run every 30 minutes
    },
}

Please see the Usage Reference for further details.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, django-owm is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @OmenApps's Cookiecutter Django Package template.

Metadata

Release files for django-owm 2024.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-owm 2024.10.2
File Size Uploaded
django_owm-2024.10.2.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-owm 2024.10.2
File Interpreter ABI Platform
django_owm-2024.10.2-py3-none-any.whl Python 3 none any Details

Total release size: 43.0 kB

Release files / django_owm-2024.10.2.tar.gz

Download URL django_owm-2024.10.2.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f2eed2d998f88071f38bc0d9f5e09c22c5576a1636214e3dd71962ce7c7910df
BLAKE2b-256 checksum
How to use checksums
60b5005dc827d6c4074cbbbbc32be410914152b5255045c75b0d6379059c4d5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release files / django_owm-2024.10.2-py3-none-any.whl

Download URL django_owm-2024.10.2-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe31b4a9ead931eaa2a4378c5a0bd81dbbf07980f83b1e4829d41f15fd387328
BLAKE2b-256 checksum
How to use checksums
7339436ce0188c3a8b57538d41e63b4ad9f1aa37f72ff990ed3dc4af66bf33ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release history Release notifications | RSS feed

This release

2024.10.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page