A Django ORM interface to operate with PyOWM domain entities
Project description
# django_pyowm
A Django ORM interface for PyOWM domain entities
## Requirements
- Django 1.10+
- PyOWM 2.5+
Python 2.7 and 3.2+ are supported.
## Install
Add `django_pyowm` to the `INSTALLED_APPS` list into your Django project's `settings.py` file:
```python
INSTALLED_APPS = [
...
'django_pyowm' # <---
]
```
Then generate tables by applying migrations:
```shell
$ python manage.py makemigrations django_pyowm
$ python manage.py migrate
```
## Features
Models behave as all other Django models but they have a few useful
functions:
- `<Model_class>.from_entity(entity)` - creates a PyOWM model instance
from the corresponding PyOWM domain object instance
- `<Model_instance>.to_entity(entity)` - turns the model instance to
the corresponding PyOWM domain object instance
## Quick usage examples
```python
from pyowm import OWM
from django_pyowm import models
# Get data an Observation from the API
owm = OWM(API_key='my_key')
obs = owm.weather_at_place('London,UK')
# Create a model instance from API response
m = models.Observation.from_entity(obs)
# Save related objects and then the model itself
m.location.save()
m.weather.save()
m.save()
# .. or save everything in one shot
m.save_all()
# From model instance to entity
original_obs = m.to_entity()
```
## Testing
```shell
$ python runtests.py
```
A Django ORM interface for PyOWM domain entities
## Requirements
- Django 1.10+
- PyOWM 2.5+
Python 2.7 and 3.2+ are supported.
## Install
Add `django_pyowm` to the `INSTALLED_APPS` list into your Django project's `settings.py` file:
```python
INSTALLED_APPS = [
...
'django_pyowm' # <---
]
```
Then generate tables by applying migrations:
```shell
$ python manage.py makemigrations django_pyowm
$ python manage.py migrate
```
## Features
Models behave as all other Django models but they have a few useful
functions:
- `<Model_class>.from_entity(entity)` - creates a PyOWM model instance
from the corresponding PyOWM domain object instance
- `<Model_instance>.to_entity(entity)` - turns the model instance to
the corresponding PyOWM domain object instance
## Quick usage examples
```python
from pyowm import OWM
from django_pyowm import models
# Get data an Observation from the API
owm = OWM(API_key='my_key')
obs = owm.weather_at_place('London,UK')
# Create a model instance from API response
m = models.Observation.from_entity(obs)
# Save related objects and then the model itself
m.location.save()
m.weather.save()
m.save()
# .. or save everything in one shot
m.save_all()
# From model instance to entity
original_obs = m.to_entity()
```
## Testing
```shell
$ python runtests.py
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_pyowm-0.1.0.tar.gz
(9.1 kB
view hashes)
Built Distributions
django_pyowm-0.1.0-py2.7.egg
(20.9 kB
view hashes)
Close
Hashes for django_pyowm-0.1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41e4f3479d29205c89b423c3ef9189a04b8d8c96ebbfa4959c01e8f22388079c |
|
MD5 | a2c79e46627d26a2537e45e99d61ba7e |
|
BLAKE2b-256 | 241c55ad7497948982deb25499ce9084682399cc2f376c27ba5df3553357e176 |