Setting up pinax-project-account on Bitnami Django Stack for Mac/Linux


Wrote a walkthrough to show you how to install a Bitnami Django 1.4.5 stack on a Mac or Linux box and then setup + deploy the pinax-project-account Django starter project with a newly created sqlite3 DB that can be accessed at localhost:8080.

Before you begin

Download the Bitnami Django native installer for your system.

This walkthrough uses the Bitnami Django 1.4.5 native installer. If you’re using a different version, please be aware that the steps may differ from this guide.

Install the native Bitnami stack

Installation Notes

  • For this example, only sqlite3 and Django are required. By only selecting what’s necessary, installing the stack will go much faster, however there is no harm in installing more than what’s necessary except for your patience.
  • Do not setup an initial project.

On Linux

$ ./[bitnami native installer]

On Mac

Run the native installer .dmg

Inside the stack environment

Step 1: Open a shell environment or Terminal (iTerm2!)

$ cd [stack location]

Step 2: Activate the stack environment

- $ ./use_djangostack
- $ . scripts/setenv.sh

Step 3: Create a new pinax accounts project

- $ cd [stack location]/apps/django/django_projects/
- $ django-admin.py startproject --template=https://github.com/pinax/pinax-project-account/zipball/master [project_name]

Step 4: Check to see if pip is installed

$ which pip

IF the path does NOT point to [stack location]/python/bin/pip

THEN pip is NOT installed. Run easy_install pip to install pip.

Step 5: Install required packages from requirements.txt

- $ cd [project_name]
- $ pip install -r requirements.txt

Step 6: Collect the static files

$ python manage.py collectstatic

Enter yes when prompted

Make note of the full path of the static files. You will need this for the next step. By default it should be at

[stack location]/apps/django/django_projects/[project_name]/[project_name]/site_media/static

Step 7: Create the sqlite3 database file

$ python manage.py syncdb

Edit settings.py

Step One: Open settings.py in a text editor. It is located at

[stack location]/apps/django/django_projects/[project_name]/[project_name]/settings.py

Step Two: Set default database name to the full path of the database created in the previous step.

Replace

DATABASES = {
    "default": {
    "ENGINE": "django.db.backends.sqlite3",
    "NAME": "dev.db",
    }
}

With

DATABASES = {
    "default": {
    "ENGINE": "django.db.backends.sqlite3",
    "NAME": "[stack location]/apps/django/django_projects/[project_name]/dev.db",
    }
}

Edit django.conf

Step One: Open django.conf in a text editor. It is located at

[stack location]/apps/django/conf/django.conf

Step Two: Modify Django app URL from localhost:8080/Project to localhost:8080

Replace

WSGIScriptAlias /Project

With

WSGIScriptAlias /

Step Three: Modify location to static file directory

Replace

Alias /static "[stack location]/apps/django/lib/python2.7/site-packages/django/contrib/admin/static"

With

Alias /site_media/static "[stack location]/apps/django/django_projects/[project_name]/[project_name]/site_media/static"

Replace

<Directory '[stack location]/apps/django/lib/python2.7/site-packages/django/contrib'>

With

<Directory '[stack location]/apps/django/django_projects/[project_name]/[project_name]/site_media/static'>

Edit django.wsgi

Step One: Open django.wsgi in a text editor. It is located at

[stack location]/apps/django/scripts/django.wsgi

Step Two: Modify location to Django project directory

Replace

sys.path.append('[stack location]/apps/django/django_projects/Project')

With

sys.path.append('[stack location]/apps/django/django_projects/[project_name]')

Step Three: Modify location to Django project settings

Replace

os.environ['DJANGO_SETTINGS_MODULE'] = 'Project.settings'

With

os.environ['DJANGO_SETTINGS_MODULE'] = '[project_name].settings'

Restart Apache

To commit the changes made up to this point, Apache must be restarted

$ ./ctlscript.sh restart apache

Your app can be found at localhost:8080

More Information

comments powered by Disqus