75 | | '''With [wiki:NewformsAdminBranch newforms-admin]''', please note that you need to override the {{{__init___}}} method in [source:django/branches/newforms-admin/django/contrib/admin/options.py your model's option class] and add TinyMCE's JavaScripts to {{{self.media}}}, which is a property. |
| 75 | '''With [wiki:NewformsAdminBranch newforms-admin]''', you have to use black magic, at the time of writing. |
| 76 | |
| 77 | If you look at [source:django/branches/newforms-admin/django/contrib/admin/options.py the AdminOptions class], you'll note that there's a {{media}} property, which generates a |
| 78 | new {{Media}} object each time you access the attribute. To get by that, we need to remake this property and "inject" our own JavaScripts. |
80 | | # Fully emulate the super function, even returning whatever from __init__, |
81 | | # in case there'll be future hackeries on the internal API. |
82 | | def __init__(self, *a, **kw): |
83 | | r = super(MyAdminOpts, self).__init__(*a, **kw) |
84 | | self.media.add_js(("http://path/to/TinyMCE/files", "http://more/paths")) |
85 | | return r |
| 83 | def _media(self): |
| 84 | media = super(MyAdminOpts, self)._media() |
| 85 | media.add_js([ |
| 86 | "http://path/to/tiny_mce.js", |
| 87 | "http://path/to/settings/"]) |
| 88 | return media |
| 89 | media = property(_media) |