'public/index.html' is a relative URL. I think the problem is probably because Apache is trying to open the directory from a place where is doesn't exist. You can make it an absolute path from the executing file by using the following code.
import os os.path.join(os.path.dirname(__file__), 'public/index.htm') However, why not use the template loaders from django? - Tom On Jan 30, 4:05 am, ts <thaisi...@gmail.com> wrote: > Hi, > > in my views.py i have the following code: > > from django.http import HttpResponse > > def index(request): > fp = open('public/index.html') > html = fp.read() > fp.close() > return HttpResponse(html) > > this works fine when i use "python manage.py runserver", and the page > serves up ok. > > but when i deploy it with apache + mod_wsgi, on that particular fp > line, i will get the exception of: > > Request Method: GET > Request URL:http://localhost/test/ > Django Version: 1.1.1 > Python Version: 2.6.1 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > Traceback: > File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" > in get_response > 92. response = callback(request, *callback_args, > **callback_kwargs) > File "/Users/test/views.py" in index > 4. fp = open('public/index.html') > > Exception Type: IOError at /test/ > Exception Value: (2, 'No such file or directory') > > any idea why i will run into this problem? > > Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.