Python is one of the first supported runtimes on Cloud9 IDE. Many of our Python users wanted to have Django supported out of the box, so we’ve added a workspace type for Django that actually installs and creates a simple Django+MySQL application just ready to Run!
To Create a Django workspace, follow these steps:
- Select the “Python / Django” workspace type, choose a name for your workspace and “Create Workspace”
- Once your workspace has been created, perform a migrate then start the Django server from the terminal (bind to host $IP and port $PORT):
python manage.py migrate python manage.py runserver $IP:$PORT
The terminal will then hint the application URL to access your application.
- Copy the link to a browser tab, or open the in-IDE previewer from ‘View -> Dock Panels -> Preview Apps’ to see the Django welcome page:
Your Django application is automatically configured to use a MySQL database for models persistence. If you like, you can use SQLite or PostgreSQL instead.
To start your workspace-hosted MySQL (as previously posted in MySQL for every workspace), type in your terminal:
Sync installed applications models to the database:
python manage.py syncdb
While following the Django tutorial, I enabled “Django Admin Interface” for models (Poll and Choice) and here is what it looks like:
- The created workspace is using Python 2.7 and Django 1.9.
- The Django website has a nice tutorial to start developing Django applications.
- Django template development with Cloud9′s previewer makes it a very neat experience.
- You can install ‘pip’ (to help you install python modules) using the Terminal:
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python