使用 mod_python 在子目录中配置 Django 项目。管理员不工作
嗨,大家好。我试图在根目录的子目录中配置我的 django 项目,但没有让事情正常工作。(本地它工作完美)。我按照 django 官方 django 文档使用 mod_python 部署了一个项目。真正的问题是,每当我尝试进入管理员或应用程序的任何视图时,我都会收到“找不到页面”错误。
这是我的 python.conf 文件,位于 Fedora 7
LoadModule python_module module/mod_python.so
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/var/www/vhosts/mysite.com/httpdocs','/var/www/vhosts/mysite.com/httpdocs/mysite'] + sys.path"
中的 /etc/httpd/conf.d/ 中。所以我知道 /var/www/ 不是放置我的 django 项目的最佳位置,但我只是想将我正在进行的工作演示发送给我的客户,稍后我将更改位置。
例如。如果我访问 www.domain.com/mysite/,我会得到在 mysite.urls 中配置的索引视图。但我无法访问我的app.urls(www.domain.com/mysite/app/)和任何admin.urls。(www.domain.com/mysite/admin/)
这是mysite.urls:
urlpatterns =patterns ('',
url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
(r'^$', 'app.views.index'),
(r'^admin/', include(admin.site.urls)),
(r'^app/', include('mysite.app.urls')),
(r'^photologue/', include('photologue.urls')),
)
我还尝试使用 ''django.contrib.admin.urls' 更改 admin.site.urls ,但没有成功。我在 google 上搜索了很多来解决这个问题,并阅读了其他开发人员如何配置他们的 django 项目,但没有找到太多在子目录中部署 django 的信息。我在 INSTALLED_APPS 中启用了管理员,并且 settings.py 没问题。
如果您有任何指导或告诉我我做错了什么,我将不胜感激。
谢谢。
HI guys. I was trying to configure my django project in a subdirectory of the root, but didn't get things working.(LOcally it works perfect). I followed the django official django documentarion to deploy a project with mod_python. The real problem is that I am getting "Page not found" errors, whenever I try to go to the admin or any view of my apps.
Here is my python.conf file located in /etc/httpd/conf.d/ in Fedora 7
LoadModule python_module modules/mod_python.so
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/var/www/vhosts/mysite.com/httpdocs','/var/www/vhosts/mysite.com/httpdocs/mysite'] + sys.path"
I know /var/www/ is not the best place to put my django project, but I just want to send a demo of my work in progress to my customer, later I will change the location.
For example. If I go to www.domain.com/mysite/ I get the index view I configured in mysite.urls. But I cannot access to my app.urls (www.domain.com/mysite/app/) and any of the admin.urls.(www.domain.com/mysite/admin/)
Here is mysite.urls:
urlpatterns = patterns('',
url(r'^admin/password_reset/
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
, 'django.contrib.auth.views.password_reset', name='password_reset'),
(r'^password_reset/done/
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
, 'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
, 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
, 'django.contrib.auth.views.password_reset_complete'),
(r'^
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
, 'app.views.index'),
(r'^admin/', include(admin.site.urls)),
(r'^app/', include('mysite.app.urls')),
(r'^photologue/', include('photologue.urls')),
)
I also tried changing admin.site.urls with ''django.contrib.admin.urls' , but it didn't worked. I googled a lot to solve this problem and read how other developers configure their django project, but didn't find too much information to deploy django in a subdirectory. I have the admin enabled in INSTALLED_APPS and the settings.py is ok.
Please if you have any guide or telling me what I am doing wrong it will be much appreciated.
THanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在使用 mod_wsgi,所以我不确定它是否都一样。但在我的 urls.py 中,我有:
在我的 Apache 配置中,我有:
您的路径可能会有所不同。
I'm using mod_wsgi, so I'm not sure if it's all the same. But in my urls.py, I have:
In my Apache config, I have this:
Your path may vary.
如果你的settings.py是正确的并且有正确的INSTALLED_APPS并且它在开发服务器中工作,那么我会说这是你的Apache配置文件。
尝试运行我的 python 应用程序来为 mod_python + Django 创建 Apache 配置文件。来源位于 github.com 的此处。一旦有了可用的配置文件,您就可以对其进行修改。
像这样运行:
结果如下:
If your settings.py is correct and has your correct INSTALLED_APPS and it works in the development server, then I'd say it's you Apache configuration file.
Try running my python app to create Apache configuration files for mod_python + Django. The source is here at github.com. Once you have a working configuration file, you can modify it.
Run like this:
Result looks like this: