Kuloto Posted February 12, 2011 Share Posted February 12, 2011 Hello, I have faced some problem with url transformations. I've configured my Django project at kuloto.heliohost.org/cartoons/ but Django gives an error as if it gets 'dispatch.wsgi' in its requests: Request Method: GET Request URL: http://kuloto.heliohost.org/cartoons/dispatch.wsgi/ Using the URLconf defined in urls, Django tried these URL patterns, in this order: ^cartoons/$ ^cartoons/gravity/$ ^cartoons/gravity/history/$ ^cartoons/gravity/([0-9.]{1,5})/$ The current URL, cartoons/dispatch.wsgi/, didn't match any of these. I tried to change patterns directly in my Django project to ^cartoons/dispatch.wsgi/gravity/$ ^cartoons/dispatch.wsgi/gravity/history/$ and so on and it begun to work but it is not good solution because all requests without trailing slash like cartoons/gravity transforms to cartoons/dispatch.wsgi/gravity/ It probably happens because Django automatically completes requests with slash. And as a result many links dont work. So my question how to configure .htaccess or whatever to avoid this behavior? .htaccess content is standard: RewriteEngine On RewriteBase / RewriteRule ^(media/.*)$ - [L] RewriteRule ^(files/.*)$ - [L] RewriteRule ^(admin_media/.*)$ - [L] RewriteRule ^(dispatch\.wsgi/.*)$ - [L] RewriteRule ^(.*)$ cartoons/dispatch.wsgi/$1 [QSA,PT,L] Quote Link to comment Share on other sites More sharing options...
Byron Posted February 12, 2011 Share Posted February 12, 2011 I don't know how to solve your problem but you might try looking at the files from this zip: http://byrondallas.heliohost.org/djangotest.zip Django Working on my site: http://byrondallas.heliohost.org/djangotest/dispatch.wsgi If you try the zip above make sure to edit these lines in wsgi to suit your site: sys.path.append("/home/byron/public_html/djangotest"); os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' os.environ['PYTHON_EGG_CACHE'] = '/home/byron/.python_egg_cache' Quote Link to comment Share on other sites More sharing options...
jje Posted February 12, 2011 Share Posted February 12, 2011 Oops - sorry. Edited previous post. Quote Link to comment Share on other sites More sharing options...
Kuloto Posted February 12, 2011 Author Share Posted February 12, 2011 to jje: Yes, Heliohost offers Django:) to byron: Thank you, but Django itself works, I have small working app with Django templates and other here, but happens something strange with inclusion of dispather file name in address. I've tried you project too with same effect (under adding some url patterns) So, I will try to read more about redirections somewhere. Quote Link to comment Share on other sites More sharing options...
Kuloto Posted February 15, 2011 Author Share Posted February 15, 2011 Hello again. After long attemptions to refit .htaccess solution proved to be nicely simple. The only thing to do is to remove or comment this line in dispatch.wsgi: environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO'] dispatch.wsgi: import os, sys sys.path.append("/home1/kuloto/public_html/cartoons/"); os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' os.environ['PYTHON_EGG_CACHE'] = '/home1/kuloto/.python_egg_cache' import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO'] #line to delete return _application(environ, start_response) It prevents adding /project_dir/dispatch.wsgi into requests to your Django program. I don't know who did add this in the script, but I'm asking admins to remove it on this page. 1 Quote Link to comment Share on other sites More sharing options...
lelewel Posted April 28, 2011 Share Posted April 28, 2011 I can second that. Please remove the line from the default script. If not for this post, I would have wasted a lot of time trying to find a workaround. Also, please add an additional info about looking up the home directory in the CPanel, as /home/{USERNAME} doesn't hold for everybody. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.