Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Oct 11, 2024
1 parent 93bc0bc commit 364ba2d
Show file tree
Hide file tree
Showing 7 changed files with 579 additions and 58 deletions.
111 changes: 104 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,122 @@
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/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

- TODO
- 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

You can install _django-owm_ via [pip] from [PyPI]:
1. Install the package using pip:

```bash
pip install django-owm
```

2. Add `'django_owm'` to your `INSTALLED_APPS` setting:

```python
INSTALLED_APPS = [
...
'django_owm',
]
```

```console
$ pip install django_owm
## Configuration

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

```python
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,
}
```

## Usage
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:

```bash
python manage.py migrate
```

## Quick Start

1. Create a new weather location:

```bash
python manage.py create_location
```

2. Fetch weather data for all locations:

```bash
python manage.py manual_weather_fetch
```

3. 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`:

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

Please see the [Command-line Reference] for details.
Please see the [Usage Reference] for further details.

## Contributing

Expand Down Expand Up @@ -68,4 +165,4 @@ This project was generated from [@OmenApps]'s [Cookiecutter Django Package] temp

[license]: https://github.com/jacklinke/django-owm/blob/main/LICENSE
[contributor guide]: https://github.com/jacklinke/django-owm/blob/main/CONTRIBUTING.md
[command-line reference]: https://django-owm.readthedocs.io/en/latest/usage.html
[usage reference]: https://django-owm.readthedocs.io/en/latest/usage.html
162 changes: 162 additions & 0 deletions docs/autoreference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Autoreference

This document is an autogenerated reference for the `django_owm` package. It provides detailed information about the modules, classes, functions, and methods available in the package.

## Table of Contents

- [Autoreference](#autoreference)
- [Table of Contents](#table-of-contents)
- [django\_owm](#django_owm)
- [admin.py](#adminpy)
- [apps.py](#appspy)
- [app\_settings.py](#app_settingspy)
- [forms.py](#formspy)
- [management/commands/](#managementcommands)
- [create\_location.py](#create_locationpy)
- [delete\_location.py](#delete_locationpy)
- [list\_locations.py](#list_locationspy)
- [manual\_weather\_fetch.py](#manual_weather_fetchpy)
- [models/](#models)
- [abstract.py](#abstractpy)
- [base.py](#basepy)
- [concrete.py](#concretepy)
- [tasks.py](#taskspy)
- [urls.py](#urlspy)
- [utils/](#utils)
- [api.py](#apipy)
- [saving.py](#savingpy)
- [validators.py](#validatorspy)
- [views.py](#viewspy)


## django_owm

```{eval-rst}
.. automodule:: django_owm
:members:
```

## admin.py

```{eval-rst}
.. automodule:: django_owm.admin
:members:
```

## apps.py

```{eval-rst}
.. automodule:: django_owm.apps
:members:
```

## app_settings.py

```{eval-rst}
.. automodule:: django_owm.app_settings
:members:
```

## forms.py

```{eval-rst}
.. automodule:: django_owm.forms
:members:
```

## management/commands/

### create_location.py

```{eval-rst}
.. automodule:: django_owm.management.commands.create_location
:members:
```

### delete_location.py

```{eval-rst}
.. automodule:: django_owm.management.commands.delete_location
:members:
```

### list_locations.py

```{eval-rst}
.. automodule:: django_owm.management.commands.list_locations
:members:
```

### manual_weather_fetch.py

```{eval-rst}
.. automodule:: django_owm.management.commands.manual_weather_fetch
:members:
```

## models/

### abstract.py

```{eval-rst}
.. automodule:: django_owm.models.abstract
:members:
```

### base.py

```{eval-rst}
.. automodule:: django_owm.models.base
:members:
```

### concrete.py

```{eval-rst}
.. automodule:: django_owm.models.concrete
:members:
```

## tasks.py

```{eval-rst}
.. automodule:: django_owm.tasks
:members:
```

## urls.py

```{eval-rst}
.. automodule:: django_owm.urls
:members:
```

## utils/

### api.py

```{eval-rst}
.. automodule:: django_owm.utils.api
:members:
```

### saving.py

```{eval-rst}
.. automodule:: django_owm.utils.saving
:members:
```

## validators.py

```{eval-rst}
.. automodule:: django_owm.validators
:members:
```

## views.py

```{eval-rst}
.. automodule:: django_owm.views
:members:
```
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ maxdepth: 1
usage
terminology
reference
autoreference
contributing
Code of Conduct <codeofconduct>
License <license>
Expand Down
Loading

0 comments on commit 364ba2d

Please sign in to comment.