Jump to content

[Solved] Django: Importerror: No Module Named Django_Test.urls


Lithonian

Recommended Posts

I'm currently developing a site to be uploaded to my account on HelioHost; but before I become too attached to Django, I decided to try uploading a "Hello, world" first, to check it would work.

 

I've created my application, and uploaded it to ~/public_html/django_test. I created ~/.python_egg_cache, and set its permissions to 777 (you might want to update your guide on the site? - 775 just caused permission errors).

 

However, when I visit my site (http://lithonian.heliohost.org/django_test/), I receive a Python ImportError:

 

CODE

ImportError at /django_test/dispatch.wsgi/

No module named django_test.urls

 

 

This is odd, because the Python path it reports is:

CODE

['/usr/lib/python2.4/site-packages/hashlib-20081119-py2.4-linux-x86_64.egg', '/usr/lib/python2.4/site-packages/elementtree-1.2.7_20070827_preview-py2.4.egg', '/usr/lib64/python24.zip', '/usr/lib64/python2.4', '/usr/lib64/python2.4/plat-linux2', '/usr/lib64/python2.4/lib-tk', '/usr/lib64/python2.4/lib-dynload', '/usr/lib64/python2.4/site-packages', '/usr/lib64/python2.4/site-packages/PIL', '/usr/lib64/python2.4/site-packages/gtk-2.0', '/usr/lib/python2.4/site-packages', '/home/lith/public_html/django_test']

 

 

And the file /home/lith/public_html/django_test/urls.py definitely exists. (Or so the file manager says... style_emoticons/default/biggrin.gif)

 

I set up my .htaccess as so (and it seems to be working OK):

CODE

RewriteEngine On

RewriteBase /

RewriteRule ^(media/.*)$ - [L]

RewriteRule ^(admin_media/.*)$ - [L]

RewriteRule ^(dispatch\.wsgi/.*)$ - [L]

RewriteRule ^(.*)$ /django_test/dispatch.wsgi/$1 [QSA,PT,L]

 

 

My dispatch.wsgi looks like this:

CODE

import os, sys

 

ScriptRoot = "/home/lith/public_html/django_test"

 

sys.path.append(ScriptRoot)

os.chdir(ScriptRoot) # Just in case! Added after it didn't work :)

 

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

os.environ['PYTHON_EGG_CACHE'] = '/home/lith/.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']

return _application(environ, start_response)

 

 

Just to highlight: my CPanel username is 'lith', and my subdomain is lithonian.heliohost.org.

Link to comment
Share on other sites

I just got this working with djbob's help yesterday:

 

http://byrondallas.heliohost.org/djangotest/dispatch.wsgi

 

Unzip this in your public_html directory and it will create a directory called 'djangotest' with all of the test files. Just make sure you change the paths.

 

http://byrondallas.heliohost.org/djangotest.zip

 

Thanks, that worked. Right now, my '^/?$' route doesn't match, understandably, because the URL is '/django_test/', however Django is using the "real" URL of '/django_test/dispatch.wsgi/'. Is there any way I can get it to match routes without the 'dispatch.wsgi'?

 

(If I should ask this in Questions rather than here, tell me. :D)

Link to comment
Share on other sites

Unfortunately, I don't think there's a way around this :(

 

OK. That's fine. I'll try writing a wrapper around urlpatterns() that adds it for me, depending on a setting in settings.py, so I can use the same URLconf for Heliohost and my home machine.

 

Thanks for your help. :)

Link to comment
Share on other sites

Wouldn't this be possible by adding this to .htaccess

RewriteBase /
RewriteRule ^$ projectname/

 

replace projectname with djangotest in this case

 

[note].htaccess in public_html

 

-----------------------------------------------

 

There is something very odd...

I uploaded the zip of byron, and I got the message: Congrats it works!

but then I saw that dispatch.wsgi was still pointing to byron

so I changed byron to kruptein, and I refreshed my site and I got: "5OO Internal Server Error"

 

So just changing byron to kruptein created an error, what is this?

Link to comment
Share on other sites

Yes I did, multiple times even because I really wanted to make sure everything was done, but I will check it again, I might forgot one thing when uploading byron's zip although I doubt that

 

Did you chmod your .python_egg_cache directory to 777?

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...