Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/islco/django-trix
Basecamp's Trix rich text editor widget for Django
https://github.com/islco/django-trix
django python trix trix-editor
Last synced: about 1 month ago
JSON representation
Basecamp's Trix rich text editor widget for Django
- Host: GitHub
- URL: https://github.com/islco/django-trix
- Owner: islco
- License: mit
- Created: 2015-10-20T15:57:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T13:47:13.000Z (8 months ago)
- Last Synced: 2024-08-09T09:39:12.450Z (5 months ago)
- Topics: django, python, trix, trix-editor
- Language: CSS
- Size: 198 KB
- Stars: 47
- Watchers: 13
- Forks: 19
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
===========
django-trix
===========`Trix rich text editor `_ widget for Django, using Trix 0.10.1.
.. image:: https://circleci.com/gh/istrategylabs/django-trix/tree/master.svg?style=shield
:target: https://circleci.com/gh/istrategylabs/django-trix/tree/master
Using 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.Model
~~~~~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 TrixFieldclass Post(models.Model):
content = TrixField('Content')Admin
~~~~~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@admin.register(Post)
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 TrixEditorclass 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::
Trix Editor Test
{{ form.media.css }}
{{ form }}
{{ form.media.js }}
CSS in head, JS at end of body, because you are a responsible developer.
Installation
------------It's on `PyPI `_::
pip install django-trix
Add to *INSTALLED_APPS*::
INSTALLED_APPS = (
...
'trix',
...
)Add route to *urls.py*::
urlpatterns = [
...
url(r'^trixorwhateveryouwant/', include('trix.urls')),
...
]TODO
----* A bunch of stuff!
* Attachment uploads