[Fixed]-Splitting "admin.py" of a Django project?

18πŸ‘

βœ…

The admin is just a python module. So the right way of splitting it would be as follows:

  • Create a folder called admin instead of admin.py
  • Use multiple files within the admin folder, like your Some_Model_admin.py
  • Create a __init__.py in the admin folder and import * all the files into it.
  • You might also want to include an __all__ to provide a clean interface.
πŸ‘€lprsd

1πŸ‘

you should be importing from Some_Model_admin instead.

from my_app.seperated_admins.Some_Model_admin import *

things should be working fine then

alternatively you can import all the split files into the init in which case

from my_app.seperated_admins import *

should work

πŸ‘€Kausikram

Leave a comment