Create your application project

You will initially create your Django projects and application outside of Bluemix. That way you will have more control over the project structure. You can start from either the flask boilerplate or the Python runtime.

  1. Create the project named projwatson:> django-admin startproject projwatsonYour project skeleton should now have been created, which you can run and see the “Hello Django” page and see the administration features.
  2. Change the directory to projwatson and start the application:projwatson> python runserver
    You should see that the server is running at

    On the https://localhost:8000/admin page, you’ll see a login prompt for to the administration page, but you will not be able to log in because you did not yet created an administrator ID.

    On the console, notice a message that says that you have unapplied migrations.

    The migrations refer to your database and models. At this point, the application is using the default Django embedded sqllite3 database.
    If you want to remove this message, you must run the migrate command as specified in the message. You will need to repeat this every time you make a database or model change. When you do make model changes, the migration is a two-step process, and you should always perform both steps together. On the initial run, the first step will show “No changes detected,” but it’s a good habit to get into every time you deploy your application changes.
    These are the actions that your application deployment must take every time there is a database schema change, including the initial deployment.

  3. Use Control <C> to interrupt the application and then generate the migration SQL:projwatson> python makemigrations
  4. Start the migrations:projwatson> python migrate
  5. Create your administrator user ID:projwatson > python createsuperusercreatesuperuser command requires user interaction, it will not work when you deploy to Bluemix, so here’s an alternative way through a Python shell.
  6. Start the shell with this command:rojwatson > python shell
  7. In the shell, create the superuser by passing in the user name, password, and email address:
    >>> from django.contrib.auth.models import User>>> User.objects.create_superuser(username='myadminid', password='mypassword', email='[email protected]')
  8. Note any exception that’s thrown. After the shell is created, if you run the create command again, you will see an IntegrityError exception. When you deploy in Bluemix, your application launch code will need to trap this exception; otherwise, the application won’t start.
  9. Exit the shell:
    >>> exit()
  10. Restart the server and log in to the administrator page at https://localhost:8000/admin.