You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Templates » import modules in to apache

Hi,
When i run on python manage.py runserver its working fine,but when I run on apache server its giving errors like,

ImportError at /mainPage
No module named mySite.modelsRequest Method: GET
Request URL: http://127.0.0.1/mainPage
Django Version: 1.3.1
Exception Type: ImportError
Exception Value: No module named mySite.models
Exception Location: //vschnws2001/share/django\myFirstSite\mySite\views.py in <module>, line 6
Python Executable: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe

Its not importing functionality from model.py so how to avoid this errors in apache,mod_wsgi.

Thanks,
Hi, in your project "myFirstSite" in app "mySite" try to see "views.py"

Exception Type: ImportError
Exception Value: No module named mySite.models
Exception Location: //vschnws2001/share/django\myFirstSite\mySite\views.py in <module>, line 6


At line 6 you have something like this: "from mySite.models import *"
Is possibile that your PYTHON_PATH is not correctly set.
If you want you can use this view to see all paths in pythonpath:
def test_paths(request):
  out = '<br>'.join(sys.path)
  return HttpResponse(out)

I think that you have also all these paths in exception page in debug mode.


--- Last Edited by arwa at 2012-02-21 07:07:13 ---
Thanks, arwa.
yes, At line 6 i have something like this: "from mySite.models import *"
My PYTHONPATH is D:\share\django\myFirstSite(Which is my current project location) fixed this from env variables.
Its working prefectly in local runserver command.
Your enviroment variables now is not used by apache/wsgi (like runserver for your user).
Probably you have an wsgi file that say how apache interprets python.
When it breaks your browser shows something like this: http://stackoverflow.com/questions/2125080/how-can-i-see-error-logs-of-django-views
After python version you have python paths.
Try to see if there is D:\share\django\myFirstSite
If is not in you must to modify wsgi file for your apache.

I hope that this info is userful for you to solve the problem.
This answers the question. (Voted by 1 users including the author of the question.)
Yes, Problem with my 'wsgi' file,fixed that and now its running fine.
ThanQ.





Powered by Sphene Community Tools