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 details)
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
django_pyowm-0.1.0-py2.7.egg
(20.9 kB
view details)
File details
Details for the file django_pyowm-0.1.0.tar.gz.
File metadata
- Download URL: django_pyowm-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
879e2f4322ea6f1149ea535c55deebfba76261cf646b93c7688fb8278b01f0a7
|
|
| MD5 |
8d35ff964ff41fdb133c2aa11ce018d6
|
|
| BLAKE2b-256 |
c0739b350408dedd3934ee818a12f8c05112a8231ee7cdf996fa79d8e3a9cc2d
|
File details
Details for the file django_pyowm-0.1.0-py2.7.egg.
File metadata
- Download URL: django_pyowm-0.1.0-py2.7.egg
- Upload date:
- Size: 20.9 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b99a9b2d7e0ed80d6b9dd8bf1ebe54e71207f4c9b41dad59cb387f1a03b2b3ff
|
|
| MD5 |
9a6fa383ef244b396e1e1d644df86ce9
|
|
| BLAKE2b-256 |
e9e530e9b496d17d11c9d4afa1003508af338760bd001e09eefb0720d6a5f6a4
|
File details
Details for the file django_pyowm-0.1.0-py2-none-any.whl.
File metadata
- Download URL: django_pyowm-0.1.0-py2-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41e4f3479d29205c89b423c3ef9189a04b8d8c96ebbfa4959c01e8f22388079c
|
|
| MD5 |
a2c79e46627d26a2537e45e99d61ba7e
|
|
| BLAKE2b-256 |
241c55ad7497948982deb25499ce9084682399cc2f376c27ba5df3553357e176
|