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.
我有一个django项目,是从github上拿的。我想在本地使用apache服务器运行这个项目。我已经安装了apache并希望运行这个项目。但我总是得到这个错误。
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.
我在mysite下有一个项目以模块名为核心。还有一个设置文件,但是我不知道为什么它没有被引用。我也不能与数据库同步。我一直在寻找一个教程,它提供了在localhost中部署一个现有django项目的详细信息。我能够创建一个新的django项目,并能够在默认端口上运行它。
2 个解决方案
#1
1
You should add the project code to PYTHONPATH.
您应该将项目代码添加到PYTHONPATH中。
The normal configuration steps:
正常配置步骤:
-
add a django.wsgi
添加一个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()导入系统,系统sys.path。附加('您的项目模块路径')#设置PYTHONPATH os。环境“DJANGO_SETTINGS_MODULE”=“核心。进口django.core.handlers设置”。wsgi应用= django.core.handlers.wsgi.WSGIHandler()
-
add django.wsgi to httpd-wsgi.conf
添加django。wsgi,httpd-wsgi.conf
WSGIScriptAlias / django.wsgi #your djang.wsgi path
WSGIScriptAlias / django。迪亚哥:wsgi #。wsgi路径
#2
0
This error will occur if you have not appended cms.modules to the sys.path.
如果没有附加cms,就会出现此错误。sys.path模块。
Use sys.path.append(/project folder path/cms.modules)
使用sys.path。追加(/项目文件夹路径/ cms.modules)
#1
1
You should add the project code to PYTHONPATH.
您应该将项目代码添加到PYTHONPATH中。
The normal configuration steps:
正常配置步骤:
-
add a django.wsgi
添加一个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()导入系统,系统sys.path。附加('您的项目模块路径')#设置PYTHONPATH os。环境“DJANGO_SETTINGS_MODULE”=“核心。进口django.core.handlers设置”。wsgi应用= django.core.handlers.wsgi.WSGIHandler()
-
add django.wsgi to httpd-wsgi.conf
添加django。wsgi,httpd-wsgi.conf
WSGIScriptAlias / django.wsgi #your djang.wsgi path
WSGIScriptAlias / django。迪亚哥:wsgi #。wsgi路径
#2
0
This error will occur if you have not appended cms.modules to the sys.path.
如果没有附加cms,就会出现此错误。sys.path模块。
Use sys.path.append(/project folder path/cms.modules)
使用sys.path。追加(/项目文件夹路径/ cms.modules)