django-ace-widget


Namedjango-ace-widget JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryDjango admin widget using ACE editor for TextField.
upload_time2024-11-16 14:20:09
maintainerrRR0VrFP
docs_urlNone
authorrRR0VrFP
requires_pythonNone
licenseApache License, Version 2.0
keywords django admin django widget ace editor django ace widget
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-ace-widget

Django admin widget using ACE editor for TextField.

## 安装

```shell
pip install django-ace-widget
```

## 使用

*app/admin.py*

```python
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参数

```python
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

- 版本首发。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-ace-widget",
    "maintainer": "rRR0VrFP",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django admin, django widget, ace editor, django ace widget",
    "author": "rRR0VrFP",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/12/cb/f3bf04f3ab8dcbdc175ab3d2ef8b62b3b649003c65c40b0f887b5ff445fb/django-ace-widget-0.1.0.tar.gz",
    "platform": null,
    "description": "# django-ace-widget\n\nDjango admin widget using ACE editor for TextField.\n\n## \u5b89\u88c5\n\n```shell\npip install django-ace-widget\n```\n\n## \u4f7f\u7528\n\n*app/admin.py*\n\n```python\nfrom django.db import models\nfrom django.contrib import admin\n\nfrom django_ace_widget.widgets import ace_widget\nfrom .models import Page\nfrom .models import Block\n\n\nclass BlockInline(admin.TabularInline):\n    model = Block\n    extra = 0\n    formfield_overrides = {\n        models.TextField: {\n            # inline\u6a21\u5f0f\u4e0b\uff0c\u4f7f\u7528100%\u663e\u793a\u4e0d\u53cb\u597d\uff0c\u8bf7\u4f7f\u7528px\u6307\u5b9a\u5bbd\u5ea6\u3002\n            \"widget\": ace_widget(\"java\", width=\"800px\"),\n        },\n    }\n\n\nclass PageAdmin(admin.ModelAdmin):\n    list_display = [\"title\"]\n    formfield_overrides = {\n        models.TextField: {\n            \"widget\": ace_widget(\"python\"),\n        },\n    }\n    inlines = [\n        BlockInline,\n    ]\n\n\nadmin.site.register(Page, PageAdmin)\n\n```\n\n## ace_widget\u53c2\u6570\n\n```python\ndef ace_widget(\n    language,\n    theme=\"xcode\",\n    width=\"100%\",\n    minLines=15,\n    maxLines=15,\n):\n    \"\"\"\u521b\u5efaAceWidget\u7c7b\u3002\n\n    \u53c2\u6570\uff1a\n        language: \u8bed\u8a00\uff0c\u5982\uff1ahtml, java, python\u7b49\u3002\n        theme: \u7f16\u8f91\u5668\u76ae\u80a4\u3002\u9ed8\u8ba4\u4e3a\uff1axcode\u3002\n        width: \u7f16\u8f91\u5668\u5bbd\u5ea6\u3002\u9ed8\u8ba4\u4e3a\uff1a100%\u3002\u53ef\u4ee5\u8bbe\u7f6e\u4e3a800px\u7b49\u3002\n        minLines: \u521d\u59cb\u884c\u6570\u3002\u9ed8\u8ba4\u4e3a\uff1a15\u3002\n        maxLines: \u6700\u5927\u884c\u6570\u3002\u9ed8\u8ba4\u4e3a\uff1a15\u3002\n\n    \u8fd4\u56de\u503c\uff1a\n        AceWidget\u7c7b\n\n    \"\"\"\n```\n\n## ace\u76ae\u80a4\n\n- clouds\n- cobalt\n- eclipse\n- nord_dark\n- dawn\n- solarized_light\n- chaos\n- monokai\n- github\n- merbivore_soft\n- katzenmilch\n- chrome\n- tomorrow\n- clouds_midnight\n- tomorrow_night_blue\n- gob\n- gruvbox\n- xcode\n- textmate\n- iplastic\n- crimson_editor\n- tomorrow_night_bright\n- mono_industrial\n- merbivore\n- sqlserver\n- idle_fingers\n- ambiance\n- kuroir\n- pastel_on_dark\n- kr_theme\n- twilight\n- solarized_dark\n- tomorrow_night\n- terminal\n- dracula\n- one_dark\n- vibrant_ink\n- tomorrow_night_eighties\n- dreamweaver\n\n## \u7248\u672c\u8bb0\u5f55\n\n### v0.1.0\n\n- \u7248\u672c\u9996\u53d1\u3002\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "Django admin widget using ACE editor for TextField.",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [
        "django admin",
        " django widget",
        " ace editor",
        " django ace widget"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d4c38a80aa269ffbcd22d6c24c8eb78b53e10a77db1b8350b60e11b1f530b6a",
                "md5": "6627e6be32d568b4083bdf5318a9d3cd",
                "sha256": "0522f8cc96a437f73a29353d688bf68ac6c4963642acfe1e41e7ee940c2781c9"
            },
            "downloads": -1,
            "filename": "django_ace_widget-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6627e6be32d568b4083bdf5318a9d3cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10025,
            "upload_time": "2024-11-16T14:20:07",
            "upload_time_iso_8601": "2024-11-16T14:20:07.835984Z",
            "url": "https://files.pythonhosted.org/packages/4d/4c/38a80aa269ffbcd22d6c24c8eb78b53e10a77db1b8350b60e11b1f530b6a/django_ace_widget-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "12cbf3bf04f3ab8dcbdc175ab3d2ef8b62b3b649003c65c40b0f887b5ff445fb",
                "md5": "a84aed8e6cfa2bfcb99739fecd99b510",
                "sha256": "f7feb0b483ad7c529e0007b790ccf5e67960cce0ed85a0d1c2f4732d05d0c195"
            },
            "downloads": -1,
            "filename": "django-ace-widget-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a84aed8e6cfa2bfcb99739fecd99b510",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9399,
            "upload_time": "2024-11-16T14:20:09",
            "upload_time_iso_8601": "2024-11-16T14:20:09.745097Z",
            "url": "https://files.pythonhosted.org/packages/12/cb/f3bf04f3ab8dcbdc175ab3d2ef8b62b3b649003c65c40b0f887b5ff445fb/django-ace-widget-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 14:20:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-ace-widget"
}
        
Elapsed time: 2.34956s