Skip to main content

Trix rich text editor widget for Django (Fork of

Project description


Trix rich text editor widget for Django, using Trix 1.2.3.


  1. From PyPI:

    pip install django-trix-fork

  2. Install trix as app in django Add to INSTALLED_APPS:

  3. Add route to

    urlpatterns = [
        url(r'^trix/', include('trix.urls')),
  4. Add django-trix variables to your app/

    # valid file extentions for attachment 
    TRIX_EXTENSIONS = ['.jpg', '.png'] 
    # folder where attachments will be saved
    TRIX_URI = 'trix' 
  5. Set-Up trix-django tables:

    python makemigrations trix
    python migrate


How to use django-trix

django-trix includes a form widget, a model field, and a model admin mixin that enables the rich text editor. You can use any of these methods, but you do not need to use all.


To enable the editor in the Django admin (or any form) via the model field, use the Trix model field TrixField which inherits from django.db.models.TextField:

from django.db import models
from trix.fields import TrixField

class Post(models.Model):
    content = TrixField('Content')


To enable the editor in the Django admin, inherit from TrixAdmin and set the trix_fields attribute to a list of the fields that use an editor:

from myawesomeblogapp.models import Post
from trix.admin import TrixAdmin

class PostAdmin(TrixAdmin, admin.ModelAdmin):
    trix_fields = ('content',)

Forms and Templates

The editor can be used in forms and templates by adding the TrixEditor widget to a form field:

from django import forms
from trix.widgets import TrixEditor

class EditorForm(forms.Form):
    content = forms.CharField(widget=TrixEditor)

In the template, just use the form as you normally would, but be sure to include the associated media:

<!doctype html>
<html lang="en">
        <meta charset="utf-8">
        <title>Trix Editor Test</title>
        {{ }}
            {{ form }}
        {{ }}

CSS in head, JS at end of body, because you are a responsible developer.

What Works

Basically Everything :) from Rich Text formatting to Uploading Attachments !

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_trix-fork- (105.2 kB view hashes)

Uploaded source

Built Distribution

django_trix_fork- (107.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page