Add support for Media class in generic forms. #20979
madgrizzle
started this conversation in
Ideas
Replies: 1 comment
-
|
@madgrizzle, the plugin development docs don't really talk about this, which indicates it's not something that we support directly via NetBox in the Plugins API. However, what is supported is using any public API exposed by Django. Since this is a plugin, the best way to handle this is probably via the Django template language's template inheritance, by:
Something like this: While that should get you started, it may take some work to find the right block to override. Good luck! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have been trying to include some javascript into the edit/add form in a plugin and used the Media class in the form definition in order to include the javascript (see https://docs.djangoproject.com/en/5.0/topics/forms/media/#media-on-forms). In my use case, I was trying to take an action when a particular text input was changed.
However, the javascript file was not loaded when the form was created. I stumbled across the need to include
{{ form.media }}in the template and I don't see this included in any of the templates thatgeneric/object_edit.htmlis extended from. I patchedbase.htmlto include the line in the head and after doing so, it loaded the javascript. I checked other pages and it didn't appear to break anything.Is this something that can be added to Netbox (within whatever is the appropriate file) or is there some other method that should be used to include javascript on a form?
Beta Was this translation helpful? Give feedback.
All reactions