3

I feel this might be a very simple question, but I am trying to learn to code using python/django so I can build some simple blog sites for my family and cannot get my site deployed on Hostmonster. I think I'm getting close, but I'm stuck with the following error:

Using the URLconf defined in newproject.urls, Django tried these URL patterns, in this order: ^admin/ The current URL, , didn't match any of these.`

I spent a bunch of time figuring out how to load python, django, etc. on my shared HostMonster account, and thought I had it all figured out when I loaded a generic, unmodified django newproject and got the django "It worked!" screen, but as soon as I uncommented the lines in urls.py and settings.py to enable the admin module, I get stuck with the above error.

Here is my .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mysite/$1
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ /mysite/jarr.fcgi [QSA,L]

and here is my jarr.fcgi file:

#!/home3/usr/python/bin/python
import sys, os
sys.path.insert(0, "/home3/usr/django/django_projects/newproject")
sys.path.insert(0, "/home3/usr/python")
sys.path.insert(0, "/home3/usr/python/lib")
sys.path.insert(0, "/home3/usr/python/lib/python2.7")
sys.path.insert(0, "/home3/usr/python/lib/python2.7/site-packages")
sys.path.insert(0, "/home3/usr/django/django_src")
os.environ['DJANGO_SETTINGS_MODULE'] = "newproject.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

So frustrating to finally get the "It worked!" from my hostmonster account after weeks of work, but then I can't even enable the admin let alone build an actual site, which is so easy on my local machine. Any advice would be very appreciated.

ronalchn
  • 12,225
  • 10
  • 51
  • 61
  • Were you able to get a solution for this? I am facing the same problem with godaddy shared hosting: http://stackoverflow.com/questions/14310086/django-on-shared-hosting-setup-issue-404-for-the-admin-url-urls-py-being-ignor – alok Jan 14 '13 at 06:39

2 Answers2

2

I have created an example django project for you, which can be easily hosted on shared hosting providers. You can find it on github - https://github.com/psjinx/django-example-project-shared-hosting.

I have answered a related question asked by alok, you may look into that as well.

If you are still having some issues then please post them in comments.

Community
  • 1
  • 1
pankaj28843
  • 2,458
  • 17
  • 34
1

Note the error message:

The current URL, , didn't match any of these.`

This means Django isn't getting any URI information. The reason is this line:

 RewriteRule ^(/)?$ mysite/jarr.fcgi [QSA,L]

Note that the only thing that can cause the fcgi script to be called is visiting the "index", and even then no URI information is given. You'll want your RewriteRule to be something like

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite/jarr.fcgi/$1 [QSA,L]

(important part is the /$1)

Try moving the jarr.fgci to the public "root" of your domain (ie, not under mysite) and change your rule to be:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ jarr.fcgi/$1 [QSA,L]

You'll still be able to put files in the directory to be served directly by apache.

DanielB
  • 2,798
  • 1
  • 19
  • 29