1. Set apache to read my django projectcat /etc/apache2/httpd.conf
(location "/")
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['[path.to.django.project]', '[path.to.other.location.which.has.python.code]'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE [projectName].settings
PythonDebug On
(/location)
where, "(" and ")" should be replaced with "<" and ">"
In web browser, http://localhost/ gives the "It worked" page of django.
If "import error" occur, check the [path.to.directory] point out the right directory which contains the module.
2. utf-8 setting$ cat /etc/apache2/envvars
...
export LANG=ko_KR.UTF-8
export LC_ALL=ko_KR.UTF-8
...
$ /etc/init.d/apache2 restart
3. Running a development server with apache mod_pythonIf a django python code was changed, apache server must be restarted.
To avoid this, just set
MaxRequestsPerChild 1
in /etc/apache2/apache2.conf
This force apache to reload everything for each request.
When debugging, use the code below to display a debugging information.
assert False, 'debug text'
4. Make database (mysql)5. Make project, appdjango-admin startproject (aaa)
cd aaa
./manage.py startapp (bbb)
in settings.py
add the code below
import os
ROOT_PATH = os.path.dirname(__file__)
add to TEMPLATE_DIRS
ROOT_PATH + '/templates',
and in INSTALLED_APPS, add
'aaa.bbb',
change the LANGUAGE_CODE option like
LANGUAGE_CODE = 'ko-KR'
and setting DB infomation.
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'dbname' # Or path to database file if using sqlite3.
DATABASE_USER = 'userid' # Not used with sqlite3.
DATABASE_PASSWORD = 'password' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
6. sync dbmanage.py syncdb
Here, set user name and password.
7.