SaltyCrane Blog — Notes on JavaScript and web development

Card store project #3: Installing Satchmo, part 2

Here are my initial steps in setting up my Satchmo store. It is meant to be a continuation of my previous post, Installing Satchmo, Django, PostgreSQL, and Apache on Ubuntu at Slicehost. I am using Satchmo version 0.8, released 2008-11-25. I am combining the instructions from the Satchmo documentation and Bruce's blog post. I'm sorry if this post is redundant-- I just wanted to have all the notes in one place for my reference. Almost all the instructions here are from one of these two sources.

Here is my final project directory structure mostly copied from Bruce's post:

`-- handsoncards/
    |-- bin/
    |-- satchmo.log
    |-- static/
    |   |-- css/
    |   |   |-- blackbird.css*
    |   |   `-- style.css
    |   |-- images/
    |   |   |-- blackbird_icons.png
    |   |   |-- blackbird_panel.png
    |   |   |-- productimage-picture-default.jpg
    |   |   `-- sample-logo.bmp
    |   |-- js/
    |   |   |-- blackbird.js
    |   |   |-- jquery.cookie.js
    |   |   |-- jquery.form.js
    |   |   |-- jquery.js
    |   |   |-- satchmo_checkout.js
    |   |   |-- satchmo_core.js
    |   |   |-- satchmo_pay_ship.js
    |   |   `-- satchmo_product.js
    |   `-- protected/
    |-- store/
    |   |--
    |   |--
    |   |-- templatetags/
    |   |   `--
    |   |--
    |   `--
    |-- templates/
    |   `-- store/

Set up project

  • Create directory structure:
    cd /srv
    mkdir HandsOnCards
    cd HandsOnCards
    /srv/Django-1.0.2-final/django/bin/ startproject handsoncards
    cd handsoncards
    mkdir bin
    mkdir -p templates/store
    ./ startapp store
    mkdir -p store/templatetags
    touch store/templatetags/
  • Create log file
    touch satchmo.log
    chmod 666 satchmo.log
  • Create the cache directory:
    mkdir django_cache
    chmod 777 django_cache
  • Copy settings files:
    cp /srv/satchmo-0.8/satchmo/
    cp /srv/satchmo-0.8/satchmo/
  • Set the Python path:
    export PYTHONPATH=/srv/python-packages:/srv/HandsOnCards
  • Copy static files:
    python satchmo_copy_static
    chmod 777 static/css
    chmod 777 static/images
    chmod 777 static/js
  • Set the root URLconf. Edit
    ROOT_URLCONF = 'handsoncards.urls'
  • Create handsoncards/store/ to only contain the following:
    from django.conf.urls.defaults import *
    from satchmo.urls import urlpatterns
  • Edit handsoncards/ to only contain the following:
    from django.conf.urls.defaults import *
    from import urlpatterns
  • Configure templates. Edit
    SATCHMO_DIRNAME = '/srv/python-packages/satchmo'
    DIRNAME = os.path.abspath(os.path.dirname(__file__).decode('utf-8'))
        os.path.join(DIRNAME, "templates/store"),
        os.path.join(DIRNAME, "templates"),
        os.path.join(SATCHMO_DIRNAME, "templates"),
    (I also commented out TEMPLATE_DIRS in since this replaces it.)
  • Install the store app. Edit
      '', #should usually be last
  • From my previous post, use the following database settings in
    DATABASE_ENGINE = 'postgresql_psycopg2'
    DATABASE_NAME = 'django_db'
    DATABASE_USER = 'django_user'
    DATABASE_PASSWORD = 'django_password'

Configure misc. settings


    (Sofeng', [email protected]'),
TIME_ZONE = 'America/Los_Angeles'
#LANGUAGE_CODE = 'en-us.utf8'
MEDIA_ROOT = os.path.join(DIRNAME, 'static/')
MEDIA_URL = '/site_media/'
ADMIN_MEDIA_PREFIX = '/admin_media/'
SECRET_KEY = 'yoursecretkeyhere'
    'SHOP_BASE' : '/shop',


CACHE_BACKEND = "file://" + DIRNAME + "/django_cache"

Test and install data

  • Set the Python path:
    export PYTHONPATH=/srv/python-packages:/srv/HandsOnCards
  • Test Satchmo setup:
    python satchmo_check
    Checking your satchmo configuration.
    Using Django version 1.0.2 final
    Using Satchmo version 0.8
    Your configuration has no errors.
  • Create database tables:
    python syncdb
    Go ahead and create a superuser
  • Load country data:
    python satchmo_load_l10n
  • Load US tax table:
    python satchmo_load_us_tax

Set up httpd.conf and static media links

  • Create symbolic links in /var/www:
    cd /var/www
    ln -s /srv/python-packages/django/contrib/admin/media admin_media
    ln -s /srv/HandsOnCards/handsoncards/static site_media
  • Edit /etc/apache2/httpd.conf:
    <location "/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE handsoncards.settings
        PythonPath "['/srv/HandsOnCards', '/srv/python-packages'] + sys.path"
        PythonDebug Off
    <location "/site_media">
        SetHandler None
    <location "/admin_media">
        SetHandler None
  • Restart apache:
    /etc/init.d/apache2 restart

View the store

Navigate to http://[your domain or slice ip address]/shop/ in your browser. You should see an empty test store.

Create a Store Configuration

  • Go to http://[your domain or slice ip address]/admin/ and log in.
  • Update the "Site". Click on "Sites". Click on "" and set your domain.
  • Under the "Shop" heading, click on "Store Configurations". Click "Add Store Configuration" and fill in the information.

Create categories and products

  • Create a Category:
    • Next to "Categories", click "Add"
    • Fill in the data
  • Create a Product:
    • Next to "Products", click "Add"
    • Fill in the data

Customize templates and CSS

  • Copy the desired templates from /srv/satchmo-0.8/satchmo/templates to /srv/HandsOnCards/handsoncards/templates/store and edit them.
  • To customize the style, edit handsoncards/static/css/style.css

Redirect '/' to '/shop/'

  • Edit handsoncards/ as follows:
    from django.conf.urls.defaults import *
    from import urlpatterns
    urlpatterns += patterns(
        (r'^$', 'django.views.generic.simple.redirect_to', {'url': '/shop/'}),


#1 Eliot commented on :

Here is a question I received through email:

Thanks for the great guide. It is really useful.

I am installing satchmo 0.8 on python 2.5.2 and Django 1.0.2 on Ubuntu 8.04. I have no problems until I come to the line...

python satchmo_copy_static

...where I get...

Unknown command: satchmo_copy_static

...what is going wrong?

Also, when I load python I can "import django" and "import satchmo" but not "import satchmo_store" as reading on your next article you have a "satchmo_store_ reference and hence I thought I would see if I could import it in python to check, but get the error "ImportError: No module named satchmo_store".

Any help or feedback is greatly appreciated, and I look forward to more of guides.

Thanks :)

Hi Babul,
Did you copy the Satchmo and over to your project? You will get this error if you don't have satchmo in your list of INSTALLED_APPS in your file.

Regarding your "import satchmo_store" error, I think "import satchmo_store" is used in the SVN trunk version of satchmo and not version 0.8.x, which I am using. I updated the link in my blog post to point to the 0.8.1 satchmo documentation instead of the SVN documentation.

I hope this answered your question.

#2 Sam commented on :


I never, ever would have been able to install this system without your guide. Well, maybe.

But it probably would have taken me a week instead of an hour.