Using drf-schema-adapter with Ember.js


In this cookbook, we will see how to create enpoints from models without building any frontend yet.

First let's kickstart our project by installing cc_djember_experience which will setup a Django project with a virtualenv and Django REST Framework pre-installed as well as a full Ember JS install pre-linked to the Django backend.

Usage of this cookiecutter is not mandatory. If you already know how to configure authentication and setting up Ember and Django to talk together, you can use your own setup; just make sure to configure export_app with the correct paths and frontend application name.

To start with this cookiecutter, you will first need to install cookiecutter globally on your computer if you haven't already done so.

$ sudo pip install cookiecutter

Once cookiecutter is installed you can go forward and bootstrap your new project:

cd <project_name>/back

If you have created a superuser while running the cookiecutter, you should be able to log-in (on the top right). You'll notice there is already one model available in the "Ember Admin".

All the info needed for that "Ember Admin" view was generated by Django (both drf_auto_endpoint and export_app)

This will launch your project, you can now open your browser at http://localhost:8000 and you will get a welcome screen. That page is created by a "composite" of Django and Ember's template engines. It is only being rendered by Django though. To get an interactive development frontend, you will need to launch Ember's development server as well (in another shell).

cd <project_name>/front

You can now point your browser at http://localhost:4200 and you should see a quite similar page. You will probably notice a few differences. Those differences come from the fact that the template has not been rendered by Django's template engine so it is missing a few variables.

Now that the base project is setup, you can refer to the main cookbook on how to create endpoints for models. After this step, you should have 2 new endpoints (catalog/products and catalog/categories). Please come back to this cookbook when you reach the end of the other one.