Changes between Version 16 and Version 17 of AddWYSIWYGEditor
- Timestamp:
- Jul 9, 2008, 10:10:48 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AddWYSIWYGEditor
v16 v17 73 73 74 74 === With newforms-admin === 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 ModelAdmin 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 !JavaScript locations. 75 Since changeset [7365] you can now add a media definition to a new ModelForm instance and assign it to your ModelAdmin instance. 79 76 80 77 {{{ 81 78 #!python 82 class MyAdminOpts(admin.ModelAdmin): 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/textarea.js"]) 88 return media 89 media = property(_media) 79 from django import newforms as forms 80 81 class PageFormWithMedia(forms.ModelForm) 82 class Media: 83 js = ('/js/tiny_mce/tiny_mce.js', 84 '/js/tiny_mce/textarea.js',) 85 86 class Meta: 87 model = MyModel 88 89 90 class MyModelOptions(admin.ModelAdmin): 91 form = PageFormWithMedia 92 93 admin.site.register(MyModel, MyModelOptions) 94 90 95 }}} 91 96