Skip to main content
# Data Models Django

[![Circle CI](https://circleci.com/gh/chop-dbhi/data-models-django/tree/master.svg?style=svg)](https://circleci.com/gh/chop-dbhi/data-models-django/tree/master) [![Coverage Status](https://coveralls.io/repos/chop-dbhi/data-models-django/badge.svg?branch=master&service=github)](https://coveralls.io/github/chop-dbhi/data-models-django?branch=master)

Django model generator for [chop-dbhi/data-models-service](https://data-model-service.research.chop.edu) style JSON metadata.

## Installation

If you're not using a Python virtual environment, please do. I prefer [pyenv](https://github.com/yyuu/pyenv) with [pyenv-virtualenv](https://github.com/yyuu/pyenv-virtualenv).

Get the most recent stable version:

```
pip install dmdj
```

Or build and install the (unstable) `HEAD` version:

```
git clone https://github.com/chop-dbhi/data-models-django.git
cd data-models-django
make install
```

## Usage

Place the following in your app's `models.py` file:

```python
import requests
from django.db import models
from dmdj.settings import get_url
from dmdj.makers import make_model

model_url = get_url('pednet', '2.1.0')
model_json = requests.get(model_url).json()

for model in make_model(model_json, (models.Model,), module='yourapp.models',
app_label='yourapp')
globals()[model.__name__] = model
```

This code causes a single web request at runtime, which may slow down your app's startup. Also, the models are dynamically generated and so may change over time, although efforts to improve the semantic versioning and stability practices in the data-models repo are under way.

## Development

### Installation

Install the development requirements and the package in "editable" mode.

```
git clone https://github.com/chop-dbhi/data-models-django.git
cd data-models-django
make devinstall
```

### Testing

Tests are run on the source code using `tox` to replicate them across the range of compatible `Django` and `Python` versions, for the `Python` versions you have available in your environment. I like to create a `dmdj` virtual environment from `3.5.x` and then use `pyenv local dmdj 3.4.x 2.7.x`

```
make test
```

### Coverage

Generate test coverage information that prints in the terminal and creates HTML and XML format files.

```
make coverage
```

## Deployment

These tasks are routinely handled by the CI/CD workflow, but I'll document them here anyway.

### Coveralls

Publish test coverage information to coveralls (the project must be registered and the token must be in the `COVERALLS_REPO_TOKEN` env var).

```
make coveralls
```

### Release

Release a new final version by pushing a new tag to GitHub and uploading the dist files to PyPi (the project must be registered at PyPi and you must have PyPi credentials available or in the `PYPI_USER` and `PYPI_PASS` env vars).

```
make release
```


Metadata

Release files for dmdj 0.4.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 dmdj 0.4.2
File Size Uploaded
dmdj-0.4.2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dmdj 0.4.2
File Interpreter ABI Platform
dmdj-0.4.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.9 kB

Release files / dmdj-0.4.2.tar.gz

Download URL dmdj-0.4.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ef2488f6f2e9eca1339ac526649e5699d6b60d06b7c258b1c9b2532ab7f3412a
BLAKE2b-256 checksum
How to use checksums
f5f86f56830e68e9c056901a83a65cdac47026b0a22a2e606522ab2e66a9f597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dmdj-0.4.2-py2.py3-none-any.whl

Download URL dmdj-0.4.2-py2.py3-none-any.whl
Size 10.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d4f55f070896c7bc02ea51685cbfb5431268badc0e461a4680550330815f7e9b
BLAKE2b-256 checksum
How to use checksums
d2e41d9d6b1b2ea8dbeb82b2ee5780c66e9edd4a08c9019ad181bd869c0fd4da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.4.0

2 release files

0.3.7

3 release files

0.3.6

3 release files

0.3.5

3 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