开发者

Django Caught an exception while rendering: No module named registration

开发者 https://www.devze.com 2023-01-02 13:06 出处:网络
I seem to have run into a bit of an issue. I am busy creating an app, and over the last few weeks setup my server to use Git, mod_wsgi to host this app.

I seem to have run into a bit of an issue.

I am busy creating an app, and over the last few weeks setup my server to use Git, mod_wsgi to host this app.

Since deploying it, everything seems to be running smoothly however, I had to go through all my files and insert the absolute url of the project to make sure it works fine.

on my local machine

from registration.models import UserRegistration

on server

from myapp.registration.models import UserRegistration

Am I doing something wrong?

And this has also caused an issue for me where I cannot 开发者_Python百科access my django admin interface.

All i get is this: Caught an exception while rendering: No module named registration

Exception Value: Caught an exception while rendering: No module named registration

As far as I am concerned my app has all the relevant urls, but it does not seem to work.

Thank you in advance


The problem is occurring because somehow your local machine is adding the myapp directory to the PYTHONPATH, as well as its parent directory. The way to fix this is to modify your .wsgi script to add both these directories to sys.path:

import sys
sys.path.insert(0, '/path/to/parent')
sys.path.insert(0, '/path/to/parent/myapp')


Read and use improved WSGI script in:

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

This will set up environment to better match Django built in development server and you shoud hopefully not see a difference between the two, especially in respect of how Python module search path is handled.

0

精彩评论

暂无评论...
验证码 换一张
取 消