Create your own online store in few hours using satchmo (django)

By : rama

What is satcmo?

Satchmo is a django based framework which allows you to create an online store very quickly. Satchmo also offers powerful customizations which allows you to tune a store to your specific business needs.

Sample Demo Store : http://www.xfgw.info/store

Login details

  1. Use below mail and password to login into the site:
    Email : test@test.com password : welcome
  2. Use dummy credit card number like 4222-2222-2222-2222 (VISA) to make any purchases.

Above is the sample demo store which is being provided by satchmo outofbox just after installing it.

In this blog post we will discuss very basic things about satchmo like how to install satchmo? , and how to do various customizations ? etc......

Installing satchmo

Please note below

  1. Installation instructions are applicable to the latest version of satchmo which is available in the trunk.
  2. We assume that python setuptools has already been installed on your system.
  3. You must have latest version of Django 1.1 beta.

Just follow the below 5 steps to install various dependencies of satchmo.

1) easy_install pycrypto
2) easy_install http://code.enthought.com/enstaller/eggs/rhel/3/Reportlab-2.1.0001-py2.5.egg
3) easy_install django-registration
4) easy_install http://tinyforge.org/frs/download.php/1/trml2pdf.tar.gz
5) easy_install PyYAML

install django-threaded-multihost

Go to : http://banjo.assembla.com/spaces/threaded_multihost/documents. Download latest .tar.gz file and follow below steps

8  tar xvzf django-threaded-multihost-1.3-0.tar.gz  
9) cd django-threaded-multihost-1.3-0 
10) python setup.py install

if you get any error as below

Traceback (most recent call last):
File "setup.py", line 1, in <module>
import ez_setup
ImportError: No module named ez_setup

Fix the above error

Open setup.py and comment out the first two lines as shown below and repeat the step 10.

# ez_setup.use_setuptools()
# from setuptools import setup, find_packages

Next install django-app-plugins app by following below steps.

11) svn checkout http://django-app-plugins.googlecode.com/svn/trunk/ django-app-plugins-read-only
12) cd /path/to/your/site-packages/dir (usually it is /usr/lib/python2.X/site-packages/)
13) ln -s /path/to/django-app-plugins-read-only/app_plugins  .

12) Installing an app means placing an app on python path so that django can find it

How do we do it?

13) By convention any directory which is in /usr/lib/python2.X/site-packages/ is on python path.Because of this we are creating a symlink from the sitepackges directory to the directory where we checkedout the latest version of django-app-plugins.Symlinking is more efficient that copying entire directory under sitepackages.

Install Sorl thumbnail app for generating thumbnails from images

14) svn checkout http://sorl-thumbnail.googlecode.com/svn/trunk/sorl/
15) cd /path/to/your/site-packages/dir
16) ln -s /path/to/sorl  .

14,15,16 We followed similar approach as that of above to install sorl-thumbnail application.

Optional dependencies

17) easy_install elementtree
18) easy_install docutils

The above are all dependencies which are required for the satchmo.

Now we will see how to create our own custom store using satchmo

create new django project

19) django-admin.py startproject customstore

check out the latest version of satchmo

20)  svn co svn://satchmoproject.com/satchmo/trunk satchmo-trunk

Install satchmo

21) cd satchmo-trunk
21) sudo python setup.py install

Make sure everything is working fine.

>>> import django
>>> django.VERSION
(1, 1, 0, 'alpha', 1)
>>> import satchmo_store
>>> satchmo_store.VERSION
(0, 9, 'pre')

Go to your project

cd customstore

copy settings.py and localsetting.py from the sample project which is provided along with satchmo.

cp  ......../satchmo-trunk/satchmo/projects/base/settings.py  ........../customstore/settings.py
cp  ......../satchmo-trunk/satchmo/projects/base/local_settings.py  ........../customstore/local_settings.py

Edit customstore/settings.py

  1. Change the Django_project name from 'satchmo' to 'satchmo_store'.In previous versions project is called as "satchmo" but now it being called as "satchmo_store"

  2. In installed apps if you find an app called "satchmo" rename it to "satchmo_store" .

Edit customstore/local_settings.py

1.Uncomment DATEBASE_NAME,DATABASE_PASSWORD,DATABASE_USER and add corresponding details of your database

DATABASE_NAME = 'satchmostore' #Name of the database which you create.Please refer to an additional note for mysql users at the end
DATABASE_PASSWORD = 'welcome'
DATABASE_USER = 'operations'

The characters which are being transferred from database server to client should be in UTF-8.if your database is MYSQL you need to add the following in local_settings.py.

DATABASE_OPTIONS = { "init_command": 'SET NAMES "utf8"' ,  "init_command":'SET storage_engine=INNODB' , }

The above command also sets INNODB as storage engine for database tables. we need to use INNODB instead of ISAM to support transactions. Uncomment SECRET_KEY and provide some value

SECRET_KEY = 'asdf'

if you are using MYSQL please note that you need to create database in UTF-8 character set as follows

 create database satchmostore  CHARACTER SET UTF-8

Edit urls.py

Copy paste the below code in the urls.py

from django.conf.urls.defaults import *
from django.conf.urls.defaults import *
from satchmo_store.urls import urlpatterns

if you have any other addtional urls you need to add at the end of urls.py as

urlpatterns += patterns('',.......)

Copy over the static content

22) python manage.py satchmo_copy_static

Check whether there are any errors in the configuration using.if there are any errors you need to resolve them before proceeding further.

23) python manage.py satchmo_check
Checking your satchmo configuration.
Using Django version 1.1 alpha 1
Using Satchmo version 0.9-pre-SVN-unknown
Your configuration has no errors.

Syncdb and load intial data

24) python manage.py syncdb
25) python manage.py satchmo_load_l10n
26) python manage.py satchmo_load_store
27) python manage.py satchmo_load_us_tax

Runserver

28) python manage.py runserver

Your store is ready.

29) http://localhost:8000/store

when you enter above URL you will be seeing a store and all the functionality which is being provided by satchmo out of box.

You can delete all the data which is provided by satchmo by running the below command

30) python manage.py delete_all_dbs

You can see all the intial settings and configuration details at

31) http://localhost:8000/settings

YOu can see the admin interface by entering the below url

32) http://localhost:8000/admin

Satchmo Customization:

Satchmo has powerfull customization mechanism using which you can tune the store to suit your business needs.The below are basic customizations which you can do.Please refer to documentation for more complex customizations and features.

To add new products and category etc

You need to go to admin interface to add new categories,products,pricing,discounts,option groups,images etc.....

More information about this details at: http://www.satchmoproject.com/docs/svn/product.html

Selling different product types

Using satchmo you can also sell products such as Downloadable Product where customer downloads data/other information after paying amount, you can also sell subscription product for which customers have to pay every month.

Custom product types

YOu can also create custom product types by following the below approach. YOu need to create a model which participates in one-to-one relation ship with the default product model as below

from django.db import models
from django.utils.translation import ugettext_lazy as _

from product.models import Product

class MyNewProduct(models.Model):
    product = models.OneToOneField(Product, verbose_name=_('Product'),
    primary_key=True)

def _get_subtype(self):
    return 'MyNewProduct'

def __unicode__(self):
    return u"MyNewProduct: %s" % self.product.name

class Admin:
    pass

class Meta:
    verbose_name = _('My New Product')
    verbose_name_plural = _('My New Products')
  1. Thereafter you need tell satchmo about this product type in config.py,add to admin.py to make it visible via admin etc..More details you can find in the below link: http://www.satchmoproject.com/docs/svn/custom-product.html

In addition to above you can do various other customizations like CSS,Template,URL,Checkout process,Shipping module customization,Payment module.

More details at satchmo documentation http://www.satchmoproject.com/docs/svn/index.html

And important details related to above customizations in the next blog post.

Stay Tuned.


Can we help you build amazing apps? Contact us today.

Topics : satchmo

Comments

rishi

satcmo is cool.... BUT If you want something hosted and easier try out FlyingCart.com - super simple shopping cart solution

commmenttor
MrSpaceman 11th April, 2009

Just in case anyone installing Satchmo on Mac OSX 10.5 had problems with doing a "python setup.py install" AND the fix recommended above didn't work either, then try the following in your terminal:

easy_install [add website link for the .egg file of django-threaded-multihost here]

For some reason this worked for me only using the .egg file, and not the .tar.gz file.

commmenttor
nttdocomo

I downloadED the latest development version of Satchmo, and installed
it follow the document in the Satchmo project website. But I
encountered a problem the same as #495, in the store website the
tumbnail url is a absolute path. I don't know is it a bug or there is
some the wrong in my setting.

python 2.62
Django 1.1 beta
Satchmo 0.9 pre

commmenttor
shabda

@nttdocomo: You would proabably get a lot of help if you asked at groups.google.com/group/satchmo-users.

commmenttor
Carl

Wow...this would make a great Plugin for WordPress. Any plans to build it out for the WordPress fans? ~Carl

commmenttor
bab

&gt;&gt; And important details related to above customizations in the next blog post

Hi,

Thanks for the excellent post. I have been waiting eagerly for several months for the follow up post.

Have you done it yet as I am really looking forward to reading it? (or am I simply missing something obvious being unable to find it???)

Thanks.

commmenttor
Sharma 6th Aug., 2010

hi I ve installed satchmo it has no errors while installing but it is giving few errors while executing these commands
25) python manage.py satchmo_load_l10n
The erros are:
Installing xml fixture 'l10n_data' from '/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-py2.6.egg/l10n/fixtures'.
Problem installing fixture '/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-py2.6.egg/l10n/fixtures/l10n_data.xml': Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/core/management/commands/loaddata.py", line 153, in handle
obj.save()
File "/usr/lib/pymodules/python2.6/django/core/serializers/base.py", line 163, in save
models.Model.save_base(self.object, raw=True)
File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line 495, in save_base
result = manager._insert(values, return_id=update_pk)
File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 1087, in insert_query
return query.execute_sql(return_id)
File "/usr/lib/pymodules/python2.6/django/db/models/sql/subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 19, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/pymodules/python2.6/django/db/backends/mysql/base.py", line 84, in execute
return self.cursor.execute(query, args)
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in execute
if not self._defer_warnings: self._warning_check()
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 82, in _warning_check
warn(w[-1], self.Warning, 3)
Warning: Incorrect string value: '&#092;xC5&#092;x9Feron' for column 'name' at row 1

26) python manage.py satchmo_load_store
The errors are:
Checking for existing sample data.
Loading sample store data.
Creating site...
Using existing site #1
Traceback (most recent call last):
File "./manage.py", line 11, in
execute_manager(settings)
File "/usr/lib/pymodules/python2.6/django/core/management/init.py", line 362, in execute_manager
utility.execute()
File "/usr/lib/pymodules/python2.6/django/core/management/init.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 195, in run_from_argv
self.execute(args, options.dict)
File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 351, in handle
return self.handle_noargs(options)
File "/usr/local/lib/python2.6/dist-packages/Satchmo-0.9_pre-py2.6.egg/satchmo_store/shop/management/commands/satchmo_load_store.py", line 40, in handle_noargs
store_country = Country.objects.get(iso3_code='USA')
File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 120, in get
return self.get_query_set().get(args, **kwargs)
File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 305, in get
% self.model._meta.object_name)
l10n.models.DoesNotExist: Country matching query does not exist.
these are the errors while configuring satchmo_store.Pl help me.
regards
Sharma

commmenttor
Robottaway

Good post, and thank you. Please, please delete that awful comment from Sharma above. This isn't a user group!

For a good tut on getting Satchmo installed for dev work check out the author's post on using virtualenv and other tools: http://www.satchmoproject.com/blog/2010/aug/01/satchmo-virtualenv/

I don't think easy_install should be needed for Satchmo installation in lieu of PIP coming on the scene.

commmenttor
Vince Watson

Its sound good satchmo helps to build online store. thanks to share such wonderful information with us..

Thanks,
Vince

commmenttor
Post a comment Name :

Email :

Your site url:

Comment :

© Agiliq, 2009-2012