Existing Django project deployment using Apache and Mod_wsgi (windows)

核能气质少年 提交于 2020-01-15 07:22:14

问题


I have a django project which I took it from github. I would like to run the project on my local using apache server. I have installed apache and want to run the project. But I am always getting this error.

 raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s"
% (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'core.settings' (Is it on sys.path?): No
module named cms.models

Please find the configuration I am using.

Python 2.7 
Django 1.4 
database in postgres

I have a project under mysite which is having the module name as core. There is also a setting files, but I dont know why it is not getting referred. I am also not able to sync with the database. I have been searching for a tutorial which gives me details of deploying a existing django project in localhost. I am able to create a new django project and able to run it in the default port.


回答1:


You should add the project code to PYTHONPATH.

The normal configuration steps:

  1. add a django.wsgi

    import os, sys
    sys.path.append('your project module path')# set PYTHONPATH
    os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings'
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()

  2. add django.wsgi to httpd-wsgi.conf

    WSGIScriptAlias / django.wsgi #your djang.wsgi path




回答2:


This error will occur if you have not appended cms.modules to the sys.path.

Use sys.path.append(/project folder path/cms.modules)



来源:https://stackoverflow.com/questions/26829698/existing-django-project-deployment-using-apache-and-mod-wsgi-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!