============
Installation
============

This guide assumes that Django is properly installed and that you have installed the
dependencies mentioned in the requirements section.

1. Get the latest Satchmo production source release::

        svn co svn://satchmoproject.com/satchmo/tags/0.6
             or download from
        http://www.satchmoproject.com/snapshots/satchmo-0.6.tar.gz


.. Note::
    If you would like the latest bleeding edge release, get it via svn-
	    svn co svn://satchmoproject.com/satchmo/trunk/
        
2. Ensure that satchmo is on your pythonpath.  There are several options for adding Satchmo to the path:
	
	- Add satchmo to the PYTHONPATH variable
	- Create a .pth file in your site-packages directory. pth_.
	- Install Satchmo in the site-packages directory

   Either way, once it's done, you should be able to do this successfully::

	$ python
	Python 2.4.2 (#1, Feb  9 2006, 05:29:30)
	[GCC 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)] on linux2
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import django
	>>> import satchmo
	>>>

   Do not attempt to progress any further on the install until the above imports work.

   The next two steps depend on whether or not Satchmo is a standalone project or just an app that is part of another Django project.

**If Satchmo is a standalone app (follow steps 3 and 4):**

3.  Modify Satchmo's default settings-customize.py file::

        cp settings-customize.py settings.py
    
4.  Modify settings.py to reflect your setup.

**If Satchmo is part of another Django app (follow step 5):**

5. Modify you project settings.py file so that it has the following line at the end::

        from local_settings import *

   Now that the basic application settings are complete, you will need to
   configure the satchmo specific items stored in local_settings.py.

6. Create your customized local_settings.py file::
    
        cp local_settings-customize.py local_settings.py

   Note that if you are installing as part of another app, you need to copy the local_settings file into that app somewhere.  It doesn't **have** to be named local_settings.  I often call it "settings_satchmo", but keep in mind that we'll be calling it "local_settings" throughout the instructions.

7.  Edit this local_settings.py file for your setup. The following values need to be changed::
		
        DATABASE_NAME = 'Your DB Name Here'
        DATABASE_PASSWORD = 'Your DB Password Here'
        DATABASE_USER = 'Your DB User Here'
        SECRET_KEY = 'Your secret key here'

   Note that if you are running as part of another app, you probably already have database settings in your master settings file.  But you will need to go through the local_settings file and make sure that everything in there is commented or uncommented appropriately.
        
   Commonly, this will include entries such as::
	
		DJANGO_PROJECT="Name of your app"
		DJANGO_SETTINGS_MODULE="yourapp.settings"
		
   You may not need these, they are probably set in your master app::
	
		SITE_NAME
		CACHE_BACKEND
		CACHE_TIMEOUT
		the logging items
		SITE_DOMAIN
		
   Lastly, note the SHOP_BASE entry.  You want to set it to the base of the shop relative to the root of the app.  Satchmo does some magic in its base urls.py module, so you need to set this appropriately.

	
8.  Unless you are running as a standalone app, you will need to merge a few settings from the satchmo settings.py files into your master app settings file.  By "merge", we mean that you should intelligently add them to the settings, without duplicating things.  Merge these settings::
	
		TEMPLATE_CONTEXT_PROCESSOR
		TEMPLATE_DIRS
		INSTALLED_APPS
		AUTHENTICATION_BACKENDS
		MIDDLEWARE_CLASSES
		
   Now, add the satchmo urls to your app.  Edit your root urls.py file, and after your urlpatterns are defined, add the satchmo urls.  Remember they will automatically appear with SHOP_BASE prepended::

	from satchmo.urls import urlpatterns as shoppatterns
	urlpatterns += shoppatterns 
	
   Copy (for windows) or symlink satchmo/tax and satchmo/load_data.py into the root of your app.
   
9.  In order to test your Satchmo setup, execute the following command::

        python manage.py satchmocheck
		
.. warning::
    The next step can erase data in the satchmo database. Be sure to have a backup of any critical data.

10.  Load the sample data::

        python load_data.py
    
11.  When prompted, enter Yes to all the questions if you want to erase everything.  This script will also install the i18n data.

12.  Start up the sample webserver to see your store::

        python manage.py runserver
        
13.  In order to see your sample store, point your browser to::
    
        http://localhost/shop to see your store

14.  If you want to see the admin interface, point your browser to::

        http://localhost/admin
        
15.  Many configuration and customization settings are accessed through the url::

        http://localhost/settings

.. note::
    The above urls will be dependent on your Django setup.  If you're running the webserver on the
    same machine you're developing on, the above urls should work.  If not, use the appropriate url.

.. _pth: http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/
