django-ace
pip install -r requirements.txt
( もしくは $ 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")},
}
もしくは、form を別途作れば別のテキストフィールドのモードを別個に設定できる
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 = (
...
※Mezzanine上で使ってもかなりいい感じになるのでおすすめ
コメント