Content

Bitnami Django for CenturyLink Cloud

Django is an open source Web development framework written in Python. It is easy to learn, highly scalable and built for security.

How to create a new superuser?

You can easily create a superuser account to access the Django admin site by following these steps, assuming that the projects folder is located at /opt/bitnami/apps/django/django_projects.

Change to your project folder:

$ cd /opt/bitnami/apps/django/django_projects/PROJECT

Create a new superuser:

$ python manage.py createsuperuser

Wait for the prompt and fill the required information to set up a new superuser.

How to deploy a Django project?

Development

For development, use the standalone server in Django by executing the following command inside your project folder:

$ python manage.py runserver SERVER-IP:PORT

SERVER-IP and PORT are optional parameters. 127.0.0.1:8000 will be used by default if you don't specify any of them. If you plan to remotely access the server, you should use the IP address 0.0.0.0, or the actual server IP address.

IMPORTANT: Remember to open the port used by the Django server in the server firewall. Refer to the FAQ for more information.

Production

For a production environment, we recommend configuring Apache with the mod_wsgi module before starting to serve your application (already installed and activated by default).

First, modify the WSGI application script file at /opt/bitnami/apps/django/django_projects/PROJECT/PROJECT/wsgi.py. Remember to replace PROJECT with the actual path and name to your Django project.

In the /opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-prefix.conf file, add this code:

Include "/opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-app.conf"

Add the line below to the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

Include "/opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-prefix.conf"

Add the line below to the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf file:

Include "/opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-vhosts.conf"

Edit the /opt/bitnami/django/django_projects/PROJECT/conf/httpd-vhosts.conf file and replace the domain within the ServerName and ServerAlias directives with the correct domain name.

Restart the Apache server.

$ sudo /opt/bitnami/ctlscript.sh restart restart apache

You should now be able to browse to your project at http://SERVER-IP/PROJECT.

How to configure a database for your project?

If you wish to configure a database for your project, configure the settings.py file with the following settings. The examples below show how to configure the database connection with a database called "djangostack".

You should now be able to see your new application at http://SERVER-IP/PROJECT/APP.

If you prefer to use the standalone server in Django, refer to this section. Note that in this case, you will need to create an SSH tunnel to port 8000 (or the port configured for the standalone server) following these instructions. In this case, you should be able to see your new application at http://localhost:8000/APP.