Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluggable apps and admin panel #13

Open
nomed opened this issue May 16, 2014 · 1 comment
Open

Pluggable apps and admin panel #13

nomed opened this issue May 16, 2014 · 1 comment

Comments

@nomed
Copy link

nomed commented May 16, 2014

I created a tgext.pluggable app with its db tables.

How can i get them on the default /admin panel ?

@barjomet
Copy link
Contributor

I know the question is three years old.
Nowadays it can be done by passing list of models to AdminController. Just replace admin = AdminController(model, DBSession, config_type=TGAdminConfig) in your RootController with

admin = AdminController(
        [getattr(models, model_name)
         for models in (model, app_model.plugged('name_of_plugged_app_here'))
         for model_name in models.__all__],
        DBSession,
        config_type=TGAdminConfig)

And of course you also need to plug app with global_models=True option and do from tgext.pluggable import app_model above your RootController definition.

devilicecream added a commit to devilicecream/tgapp-registration that referenced this issue Jan 5, 2018
Using as a reference the method provided in TurboGears/tgext.pluggable#13, to achieve compatibility with the admin panel all pluggables' models need to list the model classes they want to expose in the admin panel through `__all__`. Using inspection on the module should work as well, but this seems to me a cleaner (and more "pythonic") solution, even if it requires fixing all pluggables that don't already implement `__all__` in their models
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants