[Answered ]-How to create project and application thru the Python with D'jango in Bluemix

2đź‘Ť

Bluemix doesn’t yet have a console where you can type the Django commands in a console like Heroku does. https://devcenter.heroku.com/articles/getting-started-with-python#start-a-console

For these two commands you have two options.

  1. If you are developing locally you can invoke these commands on your local Django app installation and then do a CF push your django app to Bluemix. You will however still have to do other commands like python manage.py makemigrations on the code that you CF pushed for these apps on the database locally but also on Bluemix. See step two for commands that must be done on the Bluemix deployed Django Cloud Foundry App.

  2. Create a bash script that includes the commands that you want to invoke inside of the script. In the example you reference look in the run.sh file you will see a “python manage.py syncdb –noinput” So you could invoke your commands in a similar way. This run.sh file is then called from within your manifest.yml file. Look in the manifest file in the example https://github.com/fe01134/djangobluemix . If you are in your app root directory and logged into the Bluemix CLI when you do a CF push your app this manifest file will get picked up and the commands will be invoke. Or from within the root of your app do a CF push app_name -c “bash ./run.sh”

You will want to debug this by carefully watching the log files. by doing a cf -logs app_name

Also you typically wouldn’t run those commands (start-project or start-app) on bluemix because the app/code will dissappear once the CF Node instance comes donw the code will also dissappear. For those commands you typically run them on the dev environment machine/client side using option 1.

You also may have to do several push commands each time to do things like populated your database and create users the first time you CF push. Then on subsequent CF Pushes you would remove the -c script to create your users/database tables since you did this the first time.

Hope this helps.

0đź‘Ť

The commands you mention there are for developing the application so you’ll still want to run them locally while you work on your app. When you want to publish to Bluemix, then you’ll create a manifest file to specify your dependencies and push the whole project as an app.

If you do need to run some commands (e.g. to get the migrations to run) then you can do that by including a script in your Procfile – but these commands for creating the apps themselves are better run on your local or dev platform.

Leave a comment