Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Package description

Project Description
# Djember Model

This project is aimed at automatically generating EmberJS models from Django REST Framework serializer definitions.
This can be done in 2 different ways:

- on-the-fly generation
- on-disk files generation

## installation

Install using pip:

pip install djember_model

Add djember_model to your `INSTALLED_APPS`:



## Usage

### On-the-fly generation

In order to generate js files on the fly, you'll have import the urls from the project add add them to your urlpatterns.


from djember_model import urls as djember_urls, settings as djember_settings

urlpatterns = [
url(r'^models/', include(djember_urls, namespace=djember_settings.URL_NAMESPACE)),

For each `ViewSet` (Ember expects the same endpoint for CRUD operations, so it's better to use `ViewSet`'s) registered on your router, this will provide a corresponding ember js model.

If you have registered the following Viewset:
```router.register('categories', CategoryViewSet)```

The corresponding (ES5) Ember model definition will now be available at http://localhost:8000/models/categories.js

This functionality is meant to be used with [ember-cli-dynamic-model]( and the recommended usage is to register all your `ViewSet`'s using the <app_name><model_name_correct_english_plural> as in `my_app/categories`.

### On-disk files generation

`djember_model` also provides a management command to generate (ES6) Ember models on disk:

```./ export_to_ember route_registered_with_the_router```

So assuming you have registered the following ViewSet:

```router.register('sample/categories', CategoryViewSet)```

you can run:

```./ export_to_ember sample/categories```

in order to generate the corresponding model.
This command will generate 3 files in you ember app:

- `app/models/sample/base/` <- always generated
- `app/models/sample/` <- only generate the file if it doen't exist yet
- `tests/unit/models/sample/` <- always generated

The fields or attributes definition will be generated in `app/models/sample/base/`; `app/models/sample/` inherits from the first file and is the place where you should add any customization to your Ember model.

## Configuration

`djember_model` comes with a series of settings that can (should) be customized:


*Default value*: ``'urls.router'`

*Used by*: Dynamic & on-disk generation

The python path to the router on which you registered your `ViewSet`'s


*Default value*: `'djember'`

*Used by*: Dynamic generation only

The name of your ember application or `modulePrefix` (found in `config/environment.js` in your ember app folder)


*Default value*: `'../front'`

*Used by*: On-disk generation only

Relative path from your Django project base to your Ember application base


*Default value*:
'BooleanField': 'boolean',
'NullBooleanField': 'boolean',
'IntegerField': 'number',
'FloatField': 'number',
'DecimalField': 'number',
'ListField': None,
'DictField': None,
'JSONField': None,

*Used by*: Dynamy & on-disk generation

Mapping from Django Model fields to ember-data attr types. Any missing mapping will be mapped as `string`. If you are using custom transforms in Ember, you probably want to update these mappings.


License information available [here](

Contributors code of conduct is available [here]( Note that this COC **will** be enforced.
Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
djember_model-0.9.3.tar.gz (13.1 kB) Copy SHA256 Checksum SHA256 Source Oct 5, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting