Skip to main content

Django admin widget using ACE editor for TextField.

Project description

django-ace-widget

Django admin widget using ACE editor for TextField.

安装

pip install django-ace-widget

使用

app/admin.py

from django.db import models
from django.contrib import admin

from django_ace_widget.widgets import ace_widget
from .models import Page
from .models import Block


class BlockInline(admin.TabularInline):
    model = Block
    extra = 0
    formfield_overrides = {
        models.TextField: {
            # inline模式下,使用100%显示不友好,请使用px指定宽度。
            "widget": ace_widget("java", width="800px"),
        },
    }


class PageAdmin(admin.ModelAdmin):
    list_display = ["title"]
    formfield_overrides = {
        models.TextField: {
            "widget": ace_widget("python"),
        },
    }
    inlines = [
        BlockInline,
    ]


admin.site.register(Page, PageAdmin)

ace_widget参数

def ace_widget(
    language,
    theme="xcode",
    width="100%",
    minLines=15,
    maxLines=15,
):
    """创建AceWidget类。

    参数:
        language: 语言,如:html, java, python等。
        theme: 编辑器皮肤。默认为:xcode。
        width: 编辑器宽度。默认为:100%。可以设置为800px等。
        minLines: 初始行数。默认为:15。
        maxLines: 最大行数。默认为:15。

    返回值:
        AceWidget类

    """

ace皮肤

  • clouds
  • cobalt
  • eclipse
  • nord_dark
  • dawn
  • solarized_light
  • chaos
  • monokai
  • github
  • merbivore_soft
  • katzenmilch
  • chrome
  • tomorrow
  • clouds_midnight
  • tomorrow_night_blue
  • gob
  • gruvbox
  • xcode
  • textmate
  • iplastic
  • crimson_editor
  • tomorrow_night_bright
  • mono_industrial
  • merbivore
  • sqlserver
  • idle_fingers
  • ambiance
  • kuroir
  • pastel_on_dark
  • kr_theme
  • twilight
  • solarized_dark
  • tomorrow_night
  • terminal
  • dracula
  • one_dark
  • vibrant_ink
  • tomorrow_night_eighties
  • dreamweaver

版本记录

v0.1.0

  • 版本首发。

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-ace-widget-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

django_ace_widget-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file django-ace-widget-0.1.0.tar.gz.

File metadata

  • Download URL: django-ace-widget-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for django-ace-widget-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7feb0b483ad7c529e0007b790ccf5e67960cce0ed85a0d1c2f4732d05d0c195
MD5 a84aed8e6cfa2bfcb99739fecd99b510
BLAKE2b-256 12cbf3bf04f3ab8dcbdc175ab3d2ef8b62b3b649003c65c40b0f887b5ff445fb

See more details on using hashes here.

File details

Details for the file django_ace_widget-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ace_widget-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0522f8cc96a437f73a29353d688bf68ac6c4963642acfe1e41e7ee940c2781c9
MD5 6627e6be32d568b4083bdf5318a9d3cd
BLAKE2b-256 4d4c38a80aa269ffbcd22d6c24c8eb78b53e10a77db1b8350b60e11b1f530b6a

See more details on using hashes here.

Supported by

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