免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3340 | 回复: 6
打印 上一主题 下一主题

Django与Apache+mod_pathon的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-25 18:19 |只看该作者 |倒序浏览
这几天真郁闷,看了limodou的Step by step的中django与apache结合的资料,我完全按照上面的做
但改了httpd.conf文件后,重新启动的时候,就不能启动,出错的原因是:
Invald command 'PythonPath' ,perhaps mis-spelled or defined
by a moudle not included in the server configuration.
上网查了一下都是一样的教程,django自带的教程也一样。都试了一边,但都是这个样子
不知道limodou看了之后能不能告诉我到底在那里出错。

我的系统是:
windows2k server +python2.4+Apache2.0.54+mod_python3.x
先安装Apache,后安装mod_python

论坛徽章:
0
2 [报告]
发表于 2006-04-25 21:31 |只看该作者
如果不能识别PythonPath我想这有可能是你的mod_python是不是没有配置正确啊。安装后有没有在httpd.conf中增加关于mod_python模块的导入啊。也就是:

LoadModule python_module modules/mod_python.so

不行的话还是仔细看mod_python的配置文档吧。

论坛徽章:
0
3 [报告]
发表于 2006-04-26 13:44 |只看该作者
set pythonpath=c:/usr/dj_project
django-admin runserver

c:/usr/dj_project换成你的工程所在的目录。

看这样行不行。

论坛徽章:
0
4 [报告]
发表于 2006-04-26 19:43 |只看该作者
谢谢各位老大的帮助!这个问题我会慢慢研究,现在主要的问题是在django开发当中,相应的资料太少了。
特别是涉及到数据库中的操作对象,现在我是看源代码一个一个功能挖掘出来的,现在看的我头都疼死了。
比较郁闷,现在还在挖那个模糊搜索的数据操作对象,我想django应该有这样的对象的。像filter,all等,这样一个重要的东西不会还要自己写吧?

论坛徽章:
0
5 [报告]
发表于 2006-04-27 20:28 |只看该作者
原帖由 ragkk 于 2006-4-26 19:43 发表
谢谢各位老大的帮助!这个问题我会慢慢研究,现在主要的问题是在django开发当中,相应的资料太少了。
特别是涉及到数据库中的操作对象,现在我是看源代码一个一个功能挖掘出来的,现在看的我头都疼死了。
比较郁 ...


这里有 django m-r 的最新的文档, 包括 db-api, model-api 等:

http://code.djangoproject.com/browser/django/branches/magic-removal/docs

另外, python shell 里可以用 dir() 直接看一个类/对象所具备的方法:


  1. >>> from django.contrib.auth.models import User
  2. >>> u = User.objects.get(username__exact='eric')
  3. >>> dir(u)
  4. ['AddManipulator', 'ChangeManipulator', 'DoesNotExist', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_collect_sub_objects', '_default_manager', '_get_FIELD_display', '_get_FIELD_filename', '_get_FIELD_height', '_get_FIELD_size', '_get_FIELD_url', '_get_FIELD_width', '_get_image_dimensions', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_meta', '_prepare', '_save_FIELD_file', '_set_related_many_to_many', 'add_to_class', 'article_set' (略)
复制代码

论坛徽章:
0
6 [报告]
发表于 2006-04-28 17:57 |只看该作者
真是郁闷,看了limodou老兄的提示,apache的确可以启动了,但还是不能工作,检查了mod_python的配置,感觉发现没什么问题。但是就是不能正常工作,看了半天也没有头绪,只有一直这样报错

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "C:\Python24\Lib\site-packages\mod_python\apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "c:\python24\lib\site-packages\Django-0.91-py2.4.egg\django\core\handlers\modpython.py", line 156, in handler
    return ModPythonHandler()(req)

  File "c:\python24\lib\site-packages\Django-0.91-py2.4.egg\django\core\handlers\modpython.py", line 116, in __call__
    from django.conf import settings

  File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\conf\__init__.py", line 11, in ?
    from django.conf import global_settings

ImportError: cannot import name global_settings

希望那位老兄看到后觉得这个error比较熟悉,给小弟一点提示。。。。。。。。。。。。。。。
急盼。。。。

论坛徽章:
0
7 [报告]
发表于 2006-05-01 10:04 |只看该作者
问题已解决
原因在于pythonpath的设置上,如果你的project在C:\下
应该写成

PythonPath "[r'c:/'] + sys.path"
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP