Introduction
django-trumbowyg is the Django-related reusable app for integrating Trumbowyg WYSIWYG editor. It is recognized as one of the best WYSIWYG editors.
Initially this package was forked from Django FS Trumbowyg package and then reworked.
Installation
Install
django-trumbowyg
usingpip
:$ pip install django-trumbowyg
Add
'trumbowyg'
to yourINSTALLED_APPS
setting:INSTALLED_APPS = ( ... 'trumbowyg', ... )
Update your
urls.py
:url(r'^trumbowyg/', include('trumbowyg.urls'))
Sometimes you might want to limit size of uploaded images, e.g. if they are too large. In this case just put in settings (if you omit this, the image will be uploaded unchanged):
TRUMBOWYG_THUMBNAIL_SIZE = (1920, 1080)
The package will look for
LANGUAGES
setting. Please make sure you have set it otherwise ALL available language files will be loaded, and apparently this is not what you want:LANGUAGES = ( ('en', 'English'), ('ru', 'Russian'), )
(Optional) If you wish image filenames to be transliterated:
TRUMBOWYG_TRANSLITERATE_FILENAME = True
Usage
Use TrumbowygWidget
in your forms:
from django.forms import ModelForm from django.contrib.admin import ModelAdmin from trumbowyg.widgets import TrumbowygWidget from your_app.models import YourModel class YourModelAdminForm(ModelForm): class Meta: model = YourModel widgets = { 'text': TrumbowygWidget(), } class YourModelAdmin(admin.ModelAdmin): form = YourModelAdminForm admin.site.register(YourModel, YourModelAdmin)