django-ace
pip install -r requirements.txt
(Alternatively, $ pip install django-ace)
'django_ace',
from django_ace import AceWidget
from django.db import models as django_models
...
formfield_overrides = {
django_models.TextField: {'widget': AceWidget(
mode="django", width="100%", height="500px")},
}
Alternatively, you can create a separate form to set different modes for different text fields
from django import forms as django_forms
class TeikeiTypeAdminForm(django_forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(* args, **kwargs)
self.fields['note'].widget = AceWidget(
mode="markdown", width="100%", height="500px")
self.fields['js_function'].widget = AceWidget(
mode="javascript", width="100%", height="500px")
class TeikeiTypeAdmin(admin.ModelAdmin):
form = TeikeiTypeAdminForm
list_display = (
...
*Highly recommended if you're using Mezzanine, as it works very well.
Comments