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/
`-- handsoncards/
|-- __init__.py
|-- bin/
|-- local_settings.py
|-- manage.py*
|-- satchmo.log
|-- settings.py
|-- 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/
| |-- __init__.py
| |-- models.py
| |-- templatetags/
| | `-- __init__.py
| |-- urls.py
| `-- views.py
|-- templates/
| `-- store/
`-- urls.py
cd /srv mkdir HandsOnCards cd HandsOnCards /srv/Django-1.0.2-final/django/bin/django-admin.py startproject handsoncards cd handsoncards mkdir bin mkdir -p templates/store ./manage.py startapp store mkdir -p store/templatetags touch store/templatetags/__init__.py
touch satchmo.log chmod 666 satchmo.log
mkdir django_cache chmod 777 django_cache
cp /srv/satchmo-0.8/satchmo/local_settings-customize.py local_settings.py cp /srv/satchmo-0.8/satchmo/settings-customize.py settings.py
export PYTHONPATH=/srv/python-packages:/srv/HandsOnCards
python manage.py satchmo_copy_static chmod 777 static/css chmod 777 static/images chmod 777 static/js
settings.py:
ROOT_URLCONF = 'handsoncards.urls'
handsoncards/store/urls.py to only contain the following:
from django.conf.urls.defaults import * from satchmo.urls import urlpatterns
handsoncards/urls.py to only contain the following:
from django.conf.urls.defaults import * from handsoncards.store.urls import urlpatterns
local_settings.py:
SATCHMO_DIRNAME = '/srv/python-packages/satchmo'
DIRNAME = os.path.abspath(os.path.dirname(__file__).decode('utf-8'))
TEMPLATE_DIRS = (
os.path.join(DIRNAME, "templates/store"),
os.path.join(DIRNAME, "templates"),
os.path.join(SATCHMO_DIRNAME, "templates"),
)
(I also commented out TEMPLATE_DIRS in settings.py since this replaces it.)
settings.py:
INSTALLED_APPS = ( [...] 'handsoncards.store', #should usually be last )
settings.py:
DATABASE_ENGINE = 'postgresql_psycopg2' DATABASE_NAME = 'django_db' DATABASE_USER = 'django_user' DATABASE_PASSWORD = 'django_password' DATABASE_HOST = '' DATABASE_PORT = ''
In settings.py:
LOCAL_DEV = False
ADMINS = (
(Sofeng', sofeng@myemail.com'),
)
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'
SATCHMO_SETTINGS = {
'SHOP_BASE' : '/shop',
[...]
}
In local_settings.py:
SITE_DOMAIN = "handsoncards.com" SITE_NAME = "HandsOnCards.com" CACHE_BACKEND = "file://" + DIRNAME + "/django_cache"
export PYTHONPATH=/srv/python-packages:/srv/HandsOnCards
python manage.py satchmo_checkResults:
Checking your satchmo configuration. Using Django version 1.0.2 final Using Satchmo version 0.8 Your configuration has no errors.
python manage.py syncdbGo ahead and create a superuser
python manage.py satchmo_load_l10n
python manage.py satchmo_load_us_tax
/var/www:
cd /var/www ln -s /srv/python-packages/django/contrib/admin/media admin_media ln -s /srv/HandsOnCards/handsoncards/static site_media
/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>
<location "/site_media">
SetHandler None
</location>
<location "/admin_media">
SetHandler None
</location>
/etc/init.d/apache2 restart
Navigate to http://[your domain or slice ip address]/shop/
in your browser. You should see an empty test store.
http://[your domain or slice ip address]/admin/ and log in./srv/satchmo-0.8/satchmo/templates
to /srv/HandsOnCards/handsoncards/templates/store and edit them.
handsoncards/static/css/style.css
handsoncards/urls.py as follows:
from django.conf.urls.defaults import *
from handsoncards.store.urls import urlpatterns
urlpatterns += patterns(
'',
(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/shop/'}),
)
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 manage.py 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 settings.py and local_settings.py over to your project? You will get this error if you don't have satchmo in your list of INSTALLED_APPS in your settings.py 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.
THANK YOU SO MUCH FOR THIS!
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.
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »