Window 下搭建OSQA系统

准备的环境

Python2.7.9

Django1.7.4

Setuptools 7.0


1.  安装python 和setuptools

python下载地址: http://www.python.org/download/

setuptools下载地址: http://pypi.python.org/pypi/setuptools

2.  添加python 和 easy_install 到系统环境变量中

例如:(c:\python2.7)(c:\python2.7/script)

3.  安装依赖

easy_install django

easy_install markdown

easy_install html5lib

easy_install south

easy_install python-openid

easy_install django-debug-toolbar

 

4.  安装数据库

MySQL - http://dev.mysql.com/downloads/mysql/

5.  获取原码

svn co http://svn.osqa.net/svnroot/osqa/trunk/

 

6.  创建数据库结构

manage.py syncdb --all
manage.py migrate forum --fake

 

7.  运行开发服务器

manage.py runserver

访问http://127.0.0.1:8000/

8.  出现以下错误可能是因为版本问题

Traceback (most recent call last):

  File "D:\Python27\lib\wsgiref\handlers.py", line 85, in run

    self.result = application(self.environ, self.start_response)

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\contrib\staticfiles\handlers.py", line 67, in _call_

    return self.application(environ, start_response)

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\core\handlers\wsgi.py", line 219, in _call_

    self.load_middleware()

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\core\handlers\base.py", line 51, in load_middleware

    raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))

ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

[30/Sep/2012 02:16:52] "GET / HTTP/1.1" 500 59

Traceback (most recent call last):

  File "D:\Python27\lib\wsgiref\handlers.py", line 85, in run

    self.result = application(self.environ, self.start_response)

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\contrib\staticfiles\handlers.py", line 67, in _call_

    return self.application(environ, start_response)

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\core\handlers\wsgi.py", line 219, in _call_

    self.load_middleware()

  File "D:\Python27\lib\site-packages\django-1.4.1-py2.7.egg\django\core\handlers\base.py", line 51, in load_middleware

    raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))

ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

解决方法:

卸载掉django1.4.1的版本,添加1.3.1版本

1.删除掉django-1.4.2-py2.7.egg

例如: D:\Python27\Lib\site-packages\django-1.4.2-py2.7.egg 

2.执行以下命令安装1.3.1版本

easy_install Django==1.3.1

 

你可能感兴趣的:(python,django,问答,qa,osqa)