django.db.models get_apps() return different results according to the server used
|Reported by:||Owned by:||nobody|
|Cc:||kilian.cavalotti@…, mattimustang@…, oliver@…, lrekucki@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Using apache2 + mod_python, the admin interface do not display all of the applications listed in
INSTALLED_APPS, while all those applications correctly appear in the main admin page using the integrated web server.
Weirder is the fact that, for the missing app, the 'should-be' admin URLs for adding or editing objects (admin/app/object/add/) can be successfully accessed. It seems that the missing application is correctly seen and working (objects actually can be managed with direct URLs), but it's not shown on the main admin page.
I narrowed the problem to the fact that
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 the applications, in
load_app() function checking for 'models' attribute behaves differently according to the server used.
hasattr(mod, 'models') call returns
False for the hostManage application 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.
h = hasattr(mod, 'models') assert False, h
load_app() function from
db/models/loading.py gives the following with mod_python:
|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
So, I can't figure out why, but the
hasattr(mod, 'models') function returns different values according to the server used. And I guess it's not thewanted behavior. ;)