Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#9127 closed (invalid)

admin.autodiscover() fails in certain structures

Reported by: panni@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: autodiscover, fails, admin, folder
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Take the following structure:
projectfolder

-> modules

-> app1

admin/
admin.py

-> app2

admin/
admin.py

settings.py
urls.py

Admin.autodiscover() as far as I know uses imp.find_module('admin', app_path), which seems to result in looking for an init.py inside the "admin/" folders of the apps, which I need for custom admin views, instead of directly using "admin.py" from the apps.

Change History (4)

comment:1 Changed 7 years ago by panni@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I should've used preformattedText for the folder structure. Here it is:

projectfolder
    -> modules
        -> app1/
            admin/ 
            admin.py

        -> app2/
            admin/ 
            admin.py

    settings.py 
    urls.py

comment:2 Changed 7 years ago by panni@…

Ah yeah, and the problem is, that those apps with "admin/" folders inside of them don't get displayed in the admin page.

comment:3 Changed 7 years ago by cgrady

  • Resolution set to invalid
  • Status changed from new to closed

this is simply how python import behavior works - project/appname/admin.py is identical to project/appname/admin/__init__.py - both would be project.appname.admin for an import

comment:4 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top