adding code for a Django admin field
I have a tinymce textarea in my django admin and I need users to be able to upload images (via AJAX) that will be linked in this textarea.
That 开发者_StackOverflow中文版would be accomplished by adding an "Image Upload" button (it's already working) in the top of the "Content" textarea.
What's the recommended way of doing that?
I can think on 2 solutions:
extending
change_form
and replacing{% for fieldset in adminform %}
for the actual fields... and when it's thecontent
field, I add this valuedynamically adding this button with javascript (find out where the
content
field is and add a<div>
before it)
A better solution, if possible, would be to override just this specific field in the admin templates. Is that possible? Or are there better solutions?
PS: this field is not part of the DB (it just uploads one or more images, saves it to the storage and returns a link that will be included on the tinymce).
maybe you could use this
formfield_overrides from the djangodocs
if not, create a subclass of modelform and overide the form of admin with ModelAdmin.form.
精彩评论