Django ACE
raw JSON → 1.43.5 verified Mon Apr 27 auth: no python
django-ace provides a Django form widget for embedding the ACE code editor. Current version 1.43.5 (bundles ACE v1.43.5). Release cadence follows ACE upstream releases.
pip install django-ace Common errors
error ModuleNotFoundError: No module named 'django_ace' ↓
cause Installed package as django-ace but tried to import as django_ace incorrectly.
fix
Ensure you have installed django-ace (pip install django-ace) and use correct import: 'from django_ace import AceWidget'.
error AttributeError: 'AceWidget' object has no attribute 'render' ↓
cause Using an older version where AceWidget might not be compatible with Django version or widget API changed.
fix
Upgrade django-ace: pip install --upgrade django-ace
error The editor shows a blank box with no text area ↓
cause Width and height not set (defaulted to None) and no CSS providing dimensions.
fix
Explicitly set widget dimensions: AceWidget(width='500px', height='300px')
Warnings
breaking In v1.38.0, default width and height changed from '500px'/'300px' to None. If you relied on defaults, your editor may collapse to zero size. ↓
fix Explicitly set width and height as strings (e.g., width='500px', height='300px') or provide CSS.
gotcha The pip package name is django-ace but Python imports use django_ace (underscore). ↓
fix Use 'from django_ace import AceWidget' not 'from ace' or 'from djangoace'.
deprecated Using width/height as positional arguments is deprecated in favor of keyword arguments. ↓
fix Always pass width and height as keyword arguments.
gotcha ACE editor is loaded from CDN by default. If you need offline use, you must configure static files or use a custom build. ↓
fix Set ace_use_cdn=False and ensure static files are collected.
Imports
- AceWidget wrong
from ace import AceWidgetcorrectfrom django_ace import AceWidget - AceMixin
from django_ace import AceMixin
Quickstart
from django_ace import AceWidget
from django import forms
# In your form class:
code = forms.CharField(widget=AceWidget(
mode='python',
theme='monokai',
width=None,
height=None,
wordwrap=True
))