django-edit-away
WIP exhibit crafter for Django for use in the digital humanities. At the moment, it provides a Tiptap rich text editor with built-in support for embedding images and Youtube videos.
Installation
TBD - right now, installing requires compiling the JavaScript dependencies via NPM. A fix is in the works.
Add django_edit_away to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# ...
'django_edit_away',
]
Usage
Add TiptapField to your models:
from django.db import models
from django_edit_away.models import TiptapField
class Description(models.Model):
body = TiptapField()
Under the hood, TiptapField stores data as a JSONField with two values, html and json_value. The convenience wrapper django_edit_away.tiptap.Tiptap provides a ready-made object for holding this data in Python. HTML sanitization is handled via Tiptap. When you use a TiptapField in a form, the data is always saved from the JSON representation in the Tiptap editor, never from the HTML representation. This means it is only possible to directly modify the stored HTML via the Django shell or direct database access. More robust HTML sanitization for these circumstances is a future work plan.
In forms
When using a Tiptap field in a form, it is necessary to call the form.media class to inject additional CSS and JavaScript:
<form id="guide-form" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.media }}
{{ form }}
<button type="submit" class="btn btn-primary">Save</button>
</form>
In templates
To display rich text content in a Django template outside of forms, call the field by its html element:
{{ object.my_tiptip_field.html|safe }}
Since the field stores the raw JSON representation, it is theoretically possible to implement a true WYSIWYG editor by calling a non-editable Tiptap instance, but there are no plans to implement this at present.
Uploading images
To take advantage of the image upload feature, you must configure your media settings and add django_edit_away.urls to your url configuration:
from django.urls import path, include
url_patterns = [
# ...
path('', include('django_edit_away.urls)),
]
The AJAX requests that make image uploads work expect the urlconf to be served from root, so it is essential to follow this configuration exactly. The path /image-upload should be considered a reserved path for projects using this package.
Uploaded and embedded images can have either the class .inline-ref or .parallax-ref. The styling of these classes is left to the user, but we hope to provide sample styling in the near future.
Embedding Youtube videos
To get embedded Youtube videos to work, you must add the following to settings.py:
SECURE_REFERRER_POLICY = 'strict-origin-when-cross-origin'
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_edit_away-0.1.1.tar.gz.
File metadata
- Download URL: django_edit_away-0.1.1.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1851c34947e9e310be1b0483e401357fb61e6ae3c9765537971914b03006961
|
|
| MD5 |
46877bf2bdf33671a962dc6a242f636b
|
|
| BLAKE2b-256 |
804d41f4d509c0f9c2e88a7768cff70cbae5233827952848fa77a1af3e48a986
|
Provenance
The following attestation bundles were made for django_edit_away-0.1.1.tar.gz:
Publisher:
publish.yml on AmericanPhilosophicalSociety/django-edit-away
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_edit_away-0.1.1.tar.gz -
Subject digest:
f1851c34947e9e310be1b0483e401357fb61e6ae3c9765537971914b03006961 - Sigstore transparency entry: 2667116477
- Sigstore integration time:
-
Permalink:
AmericanPhilosophicalSociety/django-edit-away@8c7e814d0d53eb6ab2061fbff56f2f5f66dd761c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AmericanPhilosophicalSociety
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c7e814d0d53eb6ab2061fbff56f2f5f66dd761c -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_edit_away-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_edit_away-0.1.1-py3-none-any.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d879aac6169e69ebdccedd32ac6883481f856c95f8d6a2976d4cdd2cceaa75f
|
|
| MD5 |
fcd28b114c790f21bff523bd6398158c
|
|
| BLAKE2b-256 |
fb69571e9090639c4003fac63829c6f010fa10b6025d4331beeb84b40eb1b1e4
|
Provenance
The following attestation bundles were made for django_edit_away-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on AmericanPhilosophicalSociety/django-edit-away
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_edit_away-0.1.1-py3-none-any.whl -
Subject digest:
4d879aac6169e69ebdccedd32ac6883481f856c95f8d6a2976d4cdd2cceaa75f - Sigstore transparency entry: 2667116513
- Sigstore integration time:
-
Permalink:
AmericanPhilosophicalSociety/django-edit-away@8c7e814d0d53eb6ab2061fbff56f2f5f66dd761c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AmericanPhilosophicalSociety
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c7e814d0d53eb6ab2061fbff56f2f5f66dd761c -
Trigger Event:
release
-
Statement type: