Jump to content

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


Recommended Posts

Posted

Right, I've tested this (http://lithonian.com/django_test for a successful page; http://lithonian.com/django_test/blahblah for an unsuccessful page.)

 

from django.conf.urls.defaults import *
from views import *
import settings

def root_urlpatterns(root):
    def inner(fst, *bf):
        return patterns('', *[(root + x[0], x[1]) for x in bf])
    return inner

root = ''
if settings.AM_ON_HELIOHOST:
    root += '^django_test/dispatch.wsgi/' # make sure you change this!
real_patterns = root_urlpatterns(root)

urlpatterns = real_patterns('',
   ('$', index_view),
)

 

Make sure you don't use the '^' anchor in your routes, as that'll break the regex, as it's just a simple string concatenation.

 

Also, I've uploaded a new ZIP which has all the required files in it, in a simple template. In the ZIP there's also a BASH script 'generate.sh'. If you run this on your home machine, it'll pipe the templates through sed to produce the final files. Then, just upload the folder via FTP.

 

Run it like:

$ bash ./generate.sh MY_USERNAME "DESTINATION"

 

DESTINATION should *not* have a slash at the beginning or end, and quote it if it has slashes, just in case. I would run it like this:

$ bash ./generate.sh lith "djtest"

 

Then I'd upload the djtest folder via FTP or CPanel. If you run it like "bash ./generate.sh lith 'my/nested/folder'", you'll need to make 'my' and 'nested ' yourself, and upload 'folder' inside. Also, ZIP files don't preserve permissions as far as I know, so you will probably have to use the "bash " prefix unless you chmod it.

 

Also, if you get an error from mv if you run it "bash ./generate.sh lith django_test", saying it can't move "django_test to django_test/django_test", ignore it. Finally, to run it on Win32, you'll need Cygwin or similar - I used the one that comes with MSysGit. The dirname utility just segfaults (I don't know why), so I've included a Python script called dirname which will work well enough for these purposes, although you'll probably have to change the shebang line.

 

djtest.zip

It's attached to the post for now because CPanel's file manager is playing up.

Posted

I'm completely confused :s I did what you say and it worked, I renamed it to dbug and changed the urls to match dbug and it still worked.. :s

when I compare the new dbug with the old I couldn't find a difference :f probably an indendation error or something

 

thanks anyway!

Posted
I think it is urls.py because of the first import.

 

Yep. I'm not a "hardcore" Apache hacker (i.e., I can configure a dev server, nothing else.), but I can write a bit of Python script to make it easier. If you add a 'AM_ON_HELIOHOST = True' then your views will be adjusted with the right prefix, so you can use the same URLconf for testing and HelioHost.

  • 1 month later...
  • 10 months later...
Guest Geoff
Posted

Umm... not sure how you bumped this post from 2010.

 

Please re-explain your problem as this is an old thread.

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