Generate Django Rest API and Ionic API services automatically

March 2020
Buy me a coffeeBuy me a coffee

Discover my new eBook and get 20% on your purchase with this coupon code : 6XGMDHWX
Django Admin ultimate guide

Each time i have a new mobile application to develop, i need to create the Ionic project plus the Django project as backend.
It is always a boring and repetitive task and a lot of copy/paste from previous projects. So i decided to create a tool which will generate the code for me and then i will just have to place the generated files into my Ionic project and my Django project.

Ionic and Django CRUD generator

This tool is named "IonicDjangoCrudGenerator" and you will find the code here

All you need to do is to include the package into your Django project

pip install  -i https://test.pypi.org/simple/ionicdjangocrudgenerator==1.0.0

Then include the ionicdjangocrudgenerator library in your INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'rest_framework',
    'ionicdjangocrudgenerator',
    ...
)

and generate the code with the command:

python manage.py generateCrud <your_application>

Files will be created into a directory named:

<your_application>_crud

And files will be:

api_views.py The Django REST API views
serializers.py The Django REST serializers
urls.py The Django REST urls
ionic_apiservice.service.ts The Ionic API service with CRUD methods for your models and some other useful methods
ionic_entities.ts The Ionic entities classes for your models

This library is still experimental but it should help you to save lot of times.