django-trix
Trix rich text editor widget for Django, using Trix 1.2.3.
Installation
-
From PyPI:
pip install django-trix-fork -
Install
trixas app in django Add to INSTALLED_APPS:INSTALLED_APPS = ( ... 'trix', ... ) -
Add route to urls.py:
urlpatterns = [ ... url(r'^trix/', include('trix.urls')), ... ] -
Add django-trix variables to your
app/settings.py:... # valid file extentions for attachment TRIX_EXTENSIONS = ['.jpg', '.png'] # folder where attachments will be saved TRIX_URI = 'trix' ... -
Set-Up trix-django tables:
python manage.py makemigrations trix python manage.py migrate
Done
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.
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 TrixField
class 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 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">
<head>
<meta charset="utf-8">
<title>Trix Editor Test</title>
{{ form.media.css }}
</head>
<body>
<form>
{{ form }}
</form>
{{ form.media.js }}
</body>
</html>
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 !
Metadata
Release files for django-trix-fork 0.3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_trix-fork-0.3.2.0.tar.gz | 105.2 kB | Without provenance | Details for django_trix-fork-0.3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_trix_fork-0.3.2.0-py3-none-any.whl | Python 3 | none | any | Details for django_trix_fork-0.3.2.0-py3-none-any.whl |
Total release size: 213.2 kB
Release files / django_trix-fork-0.3.2.0.tar.gz
| Download URL | django_trix-fork-0.3.2.0.tar.gz |
|---|---|
| Size | 105.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
142ba5145494a84bd9e2a4a0c7f3ba58ca0c4f2fdd3efa4535d83d971a666c38
|
|
BLAKE2b-256 checksum How to use checksums |
8ae6a5abc2c125c860aed6d230fb0d21e6d431a575396dd93ed3afb1d5523e02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|
Release files / django_trix_fork-0.3.2.0-py3-none-any.whl
| Download URL | django_trix_fork-0.3.2.0-py3-none-any.whl |
|---|---|
| Size | 107.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b57bf0f14e59919e5f2a8877a0ff6a48fc58b60621ef8fd2f4a605549afff7b
|
|
BLAKE2b-256 checksum How to use checksums |
06b1a612f69ad15867285c22c1af09dd8649fc4fec65f857dfab46af0c6f6c53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
|
Security for django-trix-fork 0.3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.