Skip to main content

A simple Django app that provides a model field and corresponding widget based on the fantastic Sir Trevor project

Project description

django-sirtrevor is a simple Django app that provides a content editing widget based on the fantastic Sir Trevor project.


IMPORTANT: This package should be considered (pre-)alpha. It is by no means feature-complete or bug-free. It is a work-in-progress and right now lacks some key features.


Quick start

  1. Install django-sirtrevor:

    pip install django-sirtrevor
  2. Add sirtrevor to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'sirtrevor',
    )
  3. Create a model that makes use of SirTrevorField:

    from django.db import models
    from sirtrevor.fields import SirTrevorField
    
    class MyModel(models.Model):
        ...
        content = SirTrevorField()
        ...
  4. Now you can …

    • see it in action in the Django admin

    • create a ModelForm from your model

    • create a plain Form and use sirtrevor.forms.SirTrevorFormField

    • use sirtrevor.widgets.SirTrevorWidget as a widget replacement for a Textarea

Configuration

Sir Trevor has a few configuration options. You can customize most of them project-wide in your settings.py or on a per-widget basis as kwargs for SirTrevorWidget.

Available options (CONFIGURATION_SETTINGS / widget_kwargs):

SIRTREVOR_BLOCK_TYPES / st_block_types

Specify an array of block types to use with the editor. Defaults to ['Text', 'List', 'Quote', 'Image', 'Video', 'Tweet', 'Heading']

SIRTREVOR_DEFAULT_TYPE / st_default_type

Specify a default block to start the editor with. Defaults to None

SIRTREVOR_BLOCK_LIMIT / st_block_limit

Set an overall total number of blocks that can be displayed. Defaults to 0

SIRTREVOR_BLOCK_TYPE_LIMITS / st_block_type_limits

Set a limit on the number of blocks that can be displayed by its type. Defaults to {}

SIRTREVOR_REQUIRED / st_required

Specify which block types are required for validatation. Defaults to None

License

MIT

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-sirtrevor-0.1.4.tar.gz (427.6 kB view details)

Uploaded Source

File details

Details for the file django-sirtrevor-0.1.4.tar.gz.

File metadata

File hashes

Hashes for django-sirtrevor-0.1.4.tar.gz
Algorithm Hash digest
SHA256 eee2835c448a6ab503c0b20762e6b822a53f7873b2b3267f2ffd04ba0a1622ed
MD5 f3397ad39a05869a89bec63ed4746bf4
BLAKE2b-256 a34bd397602391de1c5b556320639611c7c2125b622612211ff0efe3bf6ce11a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page