﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7736	Differences in loading of applications between development server and mod_python	Petr Marhoun <petr.marhoun@…>	nobody	"I create simple module for demonstration of the problem - this module is called ""servers"". Its file settings.py:

{{{
#!python
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'servers.db'
INSTALLED_APPS = 'django.contrib.contenttypes', 'django.contrib.auth', 'servers',
ROOT_URLCONF = 'servers.urls'
}}}

In models.py I add new field for User model:

{{{
#!python
from django.contrib.auth.models import User
from django.db import models

User.add_to_class('language', models.CharField(max_length=255, default='en'))
}}}

In urls.py I use this new field:

{{{
#!python
from django.conf.urls.defaults import *
from django.contrib.auth.models import User
from django.http import HttpResponse

field = User._meta.get_field('language')

def index(request):
    return HttpResponse(field, 'text/plain')

urlpatterns = patterns('',
    url(r'^servers/$', index),
)
}}}

With development server it works as I expect:

{{{
<django.db.models.fields.CharField object at 0xec0590>
}}}

But with mod_python there is an error:

{{{
ImproperlyConfigured: Error while importing URLconf 'servers.urls': User has no field named 'language'
}}}

But problem disappears if I add to the django.core.handlers.modpython.!ModPythonHandler.call:

{{{
        # Load all applications.
        from django.db.models import get_apps
        get_apps()
}}}

So it seems that not all applications are loaded with mod_python."		closed	Core (Other)	dev		invalid			Unreviewed	1	0	0	0	0	0
