Skip to main content

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

django_edit_away-0.1.3.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_edit_away-0.1.3-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file django_edit_away-0.1.3.tar.gz.

File metadata

  • Download URL: django_edit_away-0.1.3.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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

Hashes for django_edit_away-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1355ebb2393e6f9a460b77a884cd0fc5107fe65779d6b31b8e9c8d3236fd9b4a
MD5 2519dc272b32ddafd3a085aa71331784
BLAKE2b-256 b60aa51600d284f614e86378ff9baa7bb3764201e2be65e593a8ad93748ef194

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_edit_away-0.1.3.tar.gz:

Publisher: publish.yml on AmericanPhilosophicalSociety/django-edit-away

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_edit_away-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_edit_away-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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

Hashes for django_edit_away-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f67d1059ea4cd976fe53c5227ab8e983d68e1db7fc9132eb5580de7f8354140
MD5 7e01f7889a67d2dfafc015e64c307f82
BLAKE2b-256 5d2c717ee50423a4c094eb9756c55a1fca85b32bff6994ef22941833e9f2c562

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_edit_away-0.1.3-py3-none-any.whl:

Publisher: publish.yml on AmericanPhilosophicalSociety/django-edit-away

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page