Reputation: 25
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 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 the content
field, I add this value
dynamically 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).
Upvotes: 1
Views: 220
Reputation: 135
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.
Upvotes: 1