#7736: Differences in loading of applications between development server and
mod_python
---------------------------------------------------+------------------------
Reporter: Petr Marhoun <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 1 |
---------------------------------------------------+------------------------
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.
--
Ticket URL: <http://code.djangoproject.com/ticket/7736>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---