0

I had already deployed my website on web server with django 1.6 and IIS7.5, it worked well.

After I upgrade develop env to django 1.8 and change my code, then I tested my site by the 'manage.py runserver' and it worked well too.

I'm using windows 8.1 and I tried to deploy the website on IIS 8.5 but I just find it didn't work, and the error report is very strange.

When I visit a url which return json, it worked well.

When I visit a url which doesn't exist, it returned django 404 page.

When I visit a normal page url, the error report is as below.

Error occurred:

Traceback (most recent call last):
  File "c:\python34\lib\site-packages\django\core\handlers\base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\myFile\project\python\MOCS\index\views.py", line 22, in index
    return render_to_response('base.html', content)
  File "c:\python34\lib\site-packages\django\shortcuts\__init__.py", line 29, in render_to_response
    return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
  File "c:\python34\lib\site-packages\django\template\loader.py", line 98, in render_to_string
    template = get_template(template_name, using=using)
  File "c:\python34\lib\site-packages\django\template\loader.py", line 35, in get_template
    return engine.get_template(template_name, dirs)
  File "c:\python34\lib\site-packages\django\template\backends\django.py", line 30, in get_template
    return Template(self.engine.get_template(template_name, dirs))
  File "c:\python34\lib\site-packages\django\template\engine.py", line 167, in get_template
    template, origin = self.find_template(template_name, dirs)
  File "c:\python34\lib\site-packages\django\template\engine.py", line 141, in find_template
    source, display_name = loader(name, dirs)
  File "c:\python34\lib\site-packages\django\template\loaders\base.py", line 13, in __call__
    return self.load_template(template_name, template_dirs)
  File "c:\python34\lib\site-packages\django\template\loaders\base.py", line 23, in load_template
    template = Template(source, origin, template_name, self.engine)
  File "c:\python34\lib\site-packages\django\template\base.py", line 190, in __init__
    self.nodelist = engine.compile_string(template_string, origin)
  File "c:\python34\lib\site-packages\django\template\engine.py", line 261, in compile_string
    return parser.parse()
  File "c:\python34\lib\site-packages\django\template\base.py", line 341, in parse
    compiled_result = compile_func(self, token)
  File "c:\python34\lib\site-packages\django\template\defaulttags.py", line 1159, in load
    lib = get_library(taglib)
  File "c:\python34\lib\site-packages\django\template\base.py", line 1387, in get_library
    templatetags_modules = get_templatetags_modules()
  File "c:\python34\lib\functools.py", line 472, in wrapper
    result = user_function(*args, **kwds)
  File "c:\python34\lib\site-packages\django\template\base.py", line 1360, in get_templatetags_modules
    for app_config in apps.get_app_configs())
  File "c:\python34\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "c:\python34\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

It seemed that the template engine didn't work.

I need some help now, thanks.

And my urls.py file is just as below

from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
# Uncomment the next two lines to enable the admin:
from django.conf import settings

urlpatterns = patterns(
    '',
    ####################index####################
    url(r'(?i)^' + settings.BASE_URL + r'$', 'index.views.index'),
    url(r'(?i)^' + settings.BASE_URL + r'login$', 'index.login.login'),
    url(r'(?i)^' + settings.BASE_URL + r'logout$', 'index.login.logout'),
    url(r'(?i)^' + settings.BASE_URL + r'ajaxTest$', 'index.views.ajaxTest'),
    url(r'(?i)^' + settings.BASE_URL + r'test$', 'index.test.test'),

)

The views.py for index is as below.

from django.template import loader, RequestContext
from django.http import HttpResponse
from django.shortcuts import render_to_response
import hashlib
import json
from django.conf import settings

def indexProcessors(request):
    "A context processor that provides 'app', 'user' and 'ip_address'."
    return {
    }

def index( request_ ):
    viewBag = {
        'pageContent': 'Hello world!',
    }
    content = RequestContext( request_, viewBag, processors= [indexProcessors] )
    return render_to_response('base.html', content)
YYLeo
  • 13
  • 5
  • how do you start a project? – i.krivosheev Jun 19 '15 at 06:52
  • @Wolkodav I just use pycharm create my website, and the project started at Django 1.6 version, do you need view my settings.py? – YYLeo Jun 19 '15 at 07:17
  • You obviously have more than just settings, as you say you're trying to view a URL. Please show the view and urls files. – Daniel Roseman Jun 19 '15 at 07:52
  • @YYLeo, do you run projects: python manage.py runserver? – i.krivosheev Jun 19 '15 at 08:25
  • See [here](http://stackoverflow.com/questions/24793351/django-appregistrynotready) or [here](http://stackoverflow.com/questions/25537905/django-1-7-throws-django-core-exceptions-appregistrynotready-models-arent-load) – i.krivosheev Jun 19 '15 at 08:26
  • @DanielRoseman I just tried, it worked well when return some json data, but it didn't work when I tried to return a template. – YYLeo Jun 23 '15 at 01:37
  • @Wolkodav Yes, it worked well, it seemed the template engine didn't work when I use IIS. – YYLeo Jun 23 '15 at 01:38

0 Answers0