I recently tried to use my django project with apache2+mod_python, after a
developement period using the integrated server. After some struggle, I
finally have a (quite) working installation. But the admin module shows a
really weird quirk. I have two custom applications, listed in
INSTALLED_APPS, and which are correctly shown in admin using the
integrated server. But when I use mod_python, one of those custom apps is
missing from the admin page.
In settings.py, I have:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'dNA.zoneConf',
'dNA.hostManage',
)
While using the integrated server (manage.py runserver), accessing the
admin page gives:
Site administration
Auth
Groups Add Change
Users Add Change
Zoneconf
<zoneconf objects>
Hostmanage
<hostmanage objects>
But using the apache server, I get:
Site administration
Auth
Groups Add Change
Users Add Change
Zoneconf
<zoneconf objects>
The hostManage module is missing, no matter in which order the apps are
listed in INSTALLED_APPS. Both servers refer to the same files, with the
same config.
Weirder is the fact that I can successfully access to the 'should-be' admin
URLs for adding or editing hostManage objects (admin/hostManage/.../add/).
So the hostManage app seems to be integrated and working (I actually can
manage objects with direct URLs), but it's not shown on the main admin
page. Any idea why?
Regards,
--
Kilian CAVALOTTI Administrateur réseaux et systèmes
UPMC / CNRS - LIP6 (C870)
8, rue du Capitaine Scott Tel. : 01 44 27 88 54
75015 Paris - France Fax. : 01 44 27 70 00
> Weirder is the fact that I can successfully access to the 'should-be'
> admin URLs for adding or editing hostManage objects
> (admin/hostManage/.../add/). So the hostManage app seems to be
> integrated and working (I actually can manage objects with direct URLs),
> but it's not shown on the main admin page. Any idea why?
I narrowed the problem to the fact that get_apps() from django.db.models
does not return the same list when called from mod_python or from the
integrated server. More precisely, it seems that for one of my
applications, in db/models/loading.py, the load_app() function checking
for 'models' attribute behaves differently according to the server used.
The hasattr(mod, 'models') call returns False for one of the
applications using mod_python, and True for the same application using the
integrated server. Thus, it's not listed in _app_list, and is not
displayed on the admin page.
I added an 'assert False, h', with h = hasattr(mod, 'models') in the
load_app() function from db/models/loading.py, and get the following with
mod_python:
assert False, h ...
▼ Local vars
Variable Value
app_name 'dNA.hostManage'
h False
mod <module 'dNA.hostManage' from '/var/www/dNA/hostManage/__init__.pyc'>
I removed *.pyc, and checked permissions on my folders and directories, but
they seems to be ok since I the hasattr(mod, 'models') works from the
shell:
>>> mod = __import__('hostManage', '', '', ['models'])
>>> mod
<module 'hostManage' from '/var/www/dNA/hostManage/__init__.pyc'>
>>> hasattr(mod, 'models')
True
After that, I'm truly lost, and I get no idea of what could be wrong. Did
anyone has any idea why the hasattr function could return different values
according to the server used?