-
-
I don't know that I agree that is_configurable must be set. I can imagine extensions that don't need any configuration to do anything, and thus won't need to present a config UI to the user, but an administration UI may be useful for tweaking stored data or performing extra queries, or just debugging.
-
-
-
-
-
-
-
I don't know that I'd bubble up an ImportError. That can be caused by any number of things. Rather, this is a configuration error. Django's ImproperlyConfigured error, with message text clearly explaining the problem, would be more appropriate.
Added support for extension admin sites
Review Request #2888 — Created Feb. 16, 2012 and submitted
This adds support for extensions to have their own admin site by setting extension.has_admin_site = True. In order to add an admin site to an extension, the following steps must be taken: 1. extension.has_admin_site = True 2. Models registered in admin.py - ex: extension_manager = get_extension_manager() extension = extension_manager.get_enabled_extension(ExtensionClassName.id) extension.admin_site.register(ModelName, ModelAdminName) The admin site will be generated and a link Database link will appear on the extension list. Currently there is a bug due to interaction between action logs from the main admin site, and the extension admin sites. Since the models for Review Board are not registered with the extension admin site, and vice versa, clicking a recent action on the admin site page which originated from the other admin site will link to an invalid url. This is a django bug, and I have filed an issue: https://code.djangoproject.com/ticket/17726
Tested by creating admin site for rbwebhooks extension.
Description | From | Last Updated |
---|---|---|
I don't know that I agree that is_configurable must be set. I can imagine extensions that don't need any configuration … |
chipx86 | |
Blank line between these. |
chipx86 | |
"Creates" |
chipx86 | |
Period after "admin site." |
chipx86 | |
Period at the end. |
chipx86 | |
Comments should always be in sentence format. Casing and period. |
chipx86 | |
You only use this in the exception case, so you probably don't want to import it yet. |
chipx86 | |
I don't know that I'd bubble up an ImportError. That can be caused by any number of things. Rather, this … |
chipx86 | |
You don't need this. It's implicit. |
chipx86 | |
Do we want to catch everything here? Seems like it's misleading to eventually raise an ImportError if this is, say, … |
chipx86 | |
Blank line between these. |
chipx86 | |
Hm...so, if I understand this correctly, if I've set up my Extension incorrectly, and had has_admin_site set to true, but … |
mike_conley |
- Change Summary:
-
Updated so that admin sites can be created with is_configurable = False. Fixed a bug where models were not being re-registered when the extensions was disabled and then re-enabled. Updated description to reflect changes.
- Description:
-
This adds support for extensions to have their own admin site by setting extension.has_admin_site = True.
In order to add an admin site to an extension, the following steps must be taken:
~ 1. extension.has_admin_site = True ~ 1. extension.has_admin_site = True - 2. extension.is_configurable = True (required for admin_urls.py to be loaded, this seems to make sense, but I'm open to input on alternatives) ~ -
Models registered in admin.py
- ex:
extension_manager = get_extension_manager()
extension = extension_manager.get_enabled_extension(ExtensionClassName.id)
extension.admin_site.register(ModelName, ModelAdminName)
- ex:
~ - Models registered in admin.py
- ex:
extension_manager = get_extension_manager()
extension = extension_manager.get_enabled_extension(ExtensionClassName.id)
extension.admin_site.register(ModelName, ModelAdminName)
- ex:
- -
a url pattern must be added to admin_urls.py
- ex:
url(r'^db/', include(extension.admin_site.urls) #adds the admin site at prefix/config/db
- ex:
~ Currently there is a bug due to interaction between action logs from the main admin site, and the extension admin sites. Since the models for Review Board are not registered with the extension admin site, and vice versa, clicking a recent action on the admin site page which originated from the other admin site will link to an invalid url. If anyone has ideas on how to fix this, I would appreciate input.
~ The admin site will be generated and a link Database link will appear on the extension list.
~ Note: this change has a parent corresponding to /r/2886
~ Currently there is a bug due to interaction between action logs from the main admin site, and the extension admin sites. Since the models for Review Board are not registered with the extension admin site, and vice versa, clicking a recent action on the admin site page which originated from the other admin site will link to an invalid url. This is a django bug, and I have filed an issue (https://code.djangoproject.com/ticket/17726).
-
- Change Summary:
-
Updated description to fix link
- Description:
-
This adds support for extensions to have their own admin site by setting extension.has_admin_site = True.
In order to add an admin site to an extension, the following steps must be taken:
1. extension.has_admin_site = True - Models registered in admin.py
- ex:
extension_manager = get_extension_manager()
extension = extension_manager.get_enabled_extension(ExtensionClassName.id)
extension.admin_site.register(ModelName, ModelAdminName)
- ex:
The admin site will be generated and a link Database link will appear on the extension list.
~ Currently there is a bug due to interaction between action logs from the main admin site, and the extension admin sites. Since the models for Review Board are not registered with the extension admin site, and vice versa, clicking a recent action on the admin site page which originated from the other admin site will link to an invalid url. This is a django bug, and I have filed an issue (https://code.djangoproject.com/ticket/17726).
~ Currently there is a bug due to interaction between action logs from the main admin site, and the extension admin sites. Since the models for Review Board are not registered with the extension admin site, and vice versa, clicking a recent action on the admin site page which originated from the other admin site will link to an invalid url. This is a django bug, and I have filed an issue: https://code.djangoproject.com/ticket/17726
- Models registered in admin.py
- Change Summary:
-
Added screenshots.
- Screenshots:
-
Extension list showing extension with admin siteExtension admin site with a single simple model
-
Hey Steven, The code looks fine to me - just one question and a possible issue below. Thanks, -Mike
-
Just curious, why did we remove the conditional checking if urlconf has the attribute "urlpatterns"?
-
Hm...so, if I understand this correctly, if I've set up my Extension incorrectly, and had has_admin_site set to true, but I don't have an admin module...the error gets swallowed? I'm not sure I agree with that. Is there a good reason?