django.db.models get_apps() return different results according to the server used
|Reported by:||kilian <kilian.cavalotti@…>||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 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 the 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 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
in the 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. ;)
Change History (21)
comment:10 Changed 7 years ago by mtredinnick
- Resolution set to fixed
- Status changed from assigned to closed
comment:11 Changed 7 years ago by aaraines@…
- Resolution fixed deleted
- Status changed from closed to reopened
- Version set to SVN