HomeProgrammingHowto use Satchmo as an App

Howto use Satchmo as an App

Note: This article is out of date. Since I wrote it, I’ve become a core developer on the Satchmo project, and Satchmo is usable by default as an App (or rather a collection of apps) rather than as the whole project. I’m going to be using Satchmo to power the backend of a highly customized store that I’m building for a new client. This is an early-stage, yet strong Python ecommerce framework, which gets much of its power by being built on Django. Of course, anyone reading my site can clearly see that I am strong in favor of that choice. I ran into one little issue when I was first setting it up according to the directions. I was told to modify files in the Satchmo directory itself. No! I won’t do it! Not on an actively developed application like that. How would I keep my modified branch in sync with the development branch?

Why is that wrong?

In general, you never want to modify something that is a moving target. Even if it is a hassle, you should set things up so that the thing-which-will-be-getting-updated is isolated from your own code. Otherwise you’ll certainly have to face that most annoying of development tasks, merging someone else’s code. Well, luckily it wasn’t so hard to set up Satchmo for use as an App, rather than as the base site. What I did was copy the settings files, and copy-for-modification one base file. It works. My directory structure: /opt/webapps/farinaz <-- my client /opt/webapps/satchmo <-- SVN checkout of satchmo here Make sure to add your base dir to your PYTHONPATH. Copy: cp satchmo/local_settings_customize.py farinaz/local_settings.py cp satchmo/settings_customize.py farinaz/settings.py cp satchmo/load_data.py farinaz/ cp satchmo/manage.py farinaz/ cp -r satchmo/static farinaz/ Modify local_settings.py (no need to modify anything in the base settings.py file)

import os
DIRNAME = os.path.dirname(__file__)

# this is useful, since satchmo is not the "current directory" like load_data expects.
SATCHMO_DIRNAME = '/opt/webapps/satchmo'

DATABASE_NAME = 'farinaz'
DATABASE_USER = 'webapp'
SECRET_KEY = 'supercalifragilisticexpealidocious'

# note these are not in the base local_settings.py
SITE_NAME = "Farinaz Taghavi"
ROOT_URLCONF = 'farinaz.urls'
MEDIA_ROOT = os.path.join(DIRNAME, 'static/')
DJANGO_PROJECT = 'farinaz'
DJANGO_SETTINGS_MODULE = 'farinaz.settings'

# this is *particularly important*.  It sets the development directory templates earlier
# on the search path than the base satchmo templates.  That way you can override only
# the ones you want
    os.path.join(DIRNAME, "templates"),
    os.path.join(SATCHMO_DIRNAME, "templates"),

Modify load_data.py, change three lines: Around line 15, give yourself the ability to override the default satchmo settings. Change the os.environ line like so:

if not os.environ.has_key("DJANGO_SETTINGS_MODULE"):

Around line 64, change site.domain and site.name to the correct settings for your site. To load the test data, just go to your site directory:

cd /opt/webapps/farinaz
export DJANGO_SETTINGS_MODULE=farinaz.settings
python load_data.py
[ ... type yes a bunch of times ...]
python manage.py test
python manage.py runserver

It works! Woo!


I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.


Sorry, the comment form is closed at this time.