TinyMCE integration for Django

Related tags

Djangodjango-tinymce
Overview

django-tinymce

django-tinymce is a Django application that contains a widget to render a form field as a TinyMCE editor.

Jazzband GitHub Actions Code coverage

Quickstart

Install django-tinymce:

$ pip install django-tinymce

Add tinymce to INSTALLED_APPS in settings.py for your project:

INSTALLED_APPS = (
    ...
    'tinymce',
)

Add tinymce.urls to urls.py for your project:

urlpatterns = [
    ...
    path('tinymce/', include('tinymce.urls')),
]

In your code:

from django.db import models
from tinymce.models import HTMLField

class MyModel(models.Model):
    ...
    content = HTMLField()

django-tinymce uses staticfiles so everything should work as expected, different use cases (like using widget instead of HTMLField) and other stuff is available in documentation.

Releases

Latest release is 3.3.0. It supports Python 3.6+ Django 2.2, 3.0 and 3.1

Using TinyMCE 5.5.0.

Previous releases can be found on github, but they are no longer maintained.

Documentation

http://django-tinymce.readthedocs.org/

Support and updates

Use github issues https://github.com/jazzband/django-tinymce/issues

License

Originally written by Joost Cassee.

This program is licensed under the MIT License (see LICENSE.txt)

Comments
  • Integrating TinyMCE 4

    Integrating TinyMCE 4

    Hi,

    Has anyone attempted to integrate the latest TinyMCE build into django-tinymce? I've currently been giving it a go, but the settings for relative_urls seem to be ignored, and my URLs are not building correctly.

    If anyone else is working on this, maybe we can work together to get this up and running? Or are there plans to upgrade at a later time?

    Thanks!

    opened by mvattuone 45
  • Has stopped working after upgrade 2.0.4 → 2.0.5

    Has stopped working after upgrade 2.0.4 → 2.0.5

    Here’s a traceback.

    /home/tanner/workspace/ROOTWELT/studio/project/env/bin/python3.4 /home/tanner/workspace/ROOTWELT/studio/project/studio/manage.py runserver
    Traceback (most recent call last):
      File "/home/tanner/workspace/ROOTWELT/studio/project/studio/manage.py", line 8, in <module>
        execute_from_command_line(sys.argv)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
        utility.execute()
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
        django.setup()
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate
        app_config = AppConfig.create(entry)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/apps/config.py", line 86, in create
        module = import_module(entry)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1129, in _exec
      File "<frozen importlib._bootstrap>", line 1471, in exec_module
      File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
      File "/home/tanner/workspace/ROOTWELT/studio/project/studio/mptt_comments/__init__.py", line 1, in <module>
        from mptt_comments.models import MPTTComment
      File "/home/tanner/workspace/ROOTWELT/studio/project/studio/mptt_comments/models.py", line 8, in <module>
        from tinymce.models import HTMLField
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/tinymce/models.py", line 6, in <module>
        from tinymce import widgets as tinymce_widgets
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/tinymce/widgets.py", line 10, in <module>
        import tinymce.settings
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/tinymce/settings.py", line 17, in <module>
        JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', finders.find('tiny_mce', all=False))
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 249, in find
        for finder in get_finders():
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 264, in get_finders
        yield get_finder(finder_path)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/functools.py", line 448, in wrapper
        result = user_function(*args, **kwds)
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 277, in get_finder
        return Finder()
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 129, in __init__
        app_configs = apps.get_app_configs()
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/apps/registry.py", line 137, in get_app_configs
        self.check_apps_ready()
      File "/home/tanner/workspace/ROOTWELT/studio/project/env/lib/python3.4/site-packages/django/apps/registry.py", line 124, in check_apps_ready
        raise AppRegistryNotReady("Apps aren't loaded yet.")
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
    
    Process finished with exit code 1
    
    bug 
    opened by jock-tanner 33
  • [Feat] refactor all tinymce module

    [Feat] refactor all tinymce module

    Hello, fellows.

    Long ago I've created task #160 to switch this module to new tinymce, and mostly I just want to entire refactor this old code. Some results:

    • switch to minified cdn version of tinymce (no need in bunch of static)
    • remove almost all views from tinymce (especially, gzip_compressor)
    • add some base selenium tests
    opened by vanadium23 23
  • Compressor not working with Django 1.5

    Compressor not working with Django 1.5

    I installed django-tinymce with pip, as suggested, so I have version 1.5.1b4 I'm using Django 1.5.

    My settings.py contains: INSTALLED_APPS = ( [omissis] 'django.contrib.staticfiles', 'tinymce', ) TINYMCE_JS_URL = os.path.join(STATIC_URL, "tiny_mce/tiny_mce_src.js") TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, "tiny_mce") TINYMCE_DEFAULT_CONFIG = { 'cleanup_on_startup': True, 'custom_undo_redo_levels':20, }

    TINYMCE_COMPRESSOR = True

    My urls.py includes url(r'^tinymce/', include('tinymce.urls')),

    If i leave the TINYMCE_COMPRESSOR = True commented out, it works and I see the WYSIWYG tool, if I uncomment it, there is a simple textbox.

    I modified templates/tinymce/tiny_mce_gzip.js adding {% load url from future %} and modified {% url tinimce-compressor %} to {% url "tinimce-compressor" %}

    otherwise Django was complaining that it "Could not parse the remainder: '-compressor' from 'tinymce-compressor'."

    opened by framazz 23
  • Uncaught ReferenceError: django is not defined ( init_tinymce.js:38 )

    Uncaught ReferenceError: django is not defined ( init_tinymce.js:38 )

    Django 1.8 and django-tinymce==2.1.0.dev0

    Unable to use django-tinymce in custom forms. Error : Uncaught ReferenceError: django is not defined ( init_tinymce.js:38 )

    The "admin" test is ok, http://django-tinymce.readthedocs.org/en/latest/installation.html#testing

    opened by lives 19
  • Allow overriding the JS_URL and JS_ROOT settings - important when staticfiles are hosted on CDN

    Allow overriding the JS_URL and JS_ROOT settings - important when staticfiles are hosted on CDN

    When Django's staticfiles are hosted externally, for example through a CDN, the same-origin policy prevents TinyMCE from functioning properly. Therefore, I made a small patch to allow overriding of JS_URL and JS_ROOT from Django's settings.

    When this setting is not specified, the original defaults are used. When they are specified, the defaults are ignored.

    opened by dokterbob 18
  • Fixed the spellchecker view as per tinymce doc

    Fixed the spellchecker view as per tinymce doc

    The spell checker was not conforming as per the documentation.

    Update the spell checker view to support it

    Note: The data received is in post as querystring . Stripping out spaces and . , : ; ' " at the end and start of any word.

    opened by tauzahmd 13
  • Update latest minor version of TinyMCE 3.5 to version 1.5

    Update latest minor version of TinyMCE 3.5 to version 1.5

    Hi,

    The django-tinymce version 1.5.3 contains TinyMCE 3.5.8 which has got several fixes after that. Could you update the TinyMCE version 3.5.12 to django-tinymce version 1.5 or do I create a fork?

    Thanks

    opened by tomijarvi 13
  • Error with multiple instances of TinyMCE

    Error with multiple instances of TinyMCE

    An error seems to have followed form the patch in #2 (thank God for git bisect. This pull request contains a reverse patch that has been verified to fix this issue - however, a real patch might still be in order.

    Original pull request by @quadracik.

    documentation bug 
    opened by dokterbob 13
  • paste_preprocess & paste_postprocess don't work when set in TINYMCE_DEFAULT_CONFIG

    paste_preprocess & paste_postprocess don't work when set in TINYMCE_DEFAULT_CONFIG

    When I try to add paste_preprocess or paste_postprocess to my TINYMCE_DEFAULT_CONFIG, I get an error saying "unexpected token p" in my web console. Here is the full traceback:

    Uncaught SyntaxError: Unexpected token p
        e.extend.parseJSON    @ jquery.min.js:2
        initTinyMCE           @ init_tinymce.js:4
        (anonymous function)  @ init_tinymce.js:21
        e.extend.each         @ jquery.min.js:2
        e.fn.e.each           @ jquery.min.js:2
        (anonymous function)  @ init_tinymce.js:20
        o                     @ jquery.min.js:2
        p.fireWith            @ jquery.min.js:2
        e.extend.ready        @ jquery.min.js:2
        c.addEventListener.B  @ jquery.min.js:2
    

    This is my configuration:

    # Tinymce Config
    TINYMCE_JS_URL = os.path.join(STATIC_URL, "tiny_mce/tiny_mce.js")
    TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, "tiny_mce")
    TINYMCE_DEFAULT_CONFIG = {
        'theme':'advanced',
        'theme_advanced_buttons1':'bold,italic,underline,|,bullist,numlist,outdent,indent,|,undo,redo,|,link,unlink',
        'menubar':'false',
        'plugins':'paste',
        'paste_text_linebreaktype':'combined',
        'paste_postprocess':"function(pl, o) { o.content = strip_tags(o.content,'<div>');}",
        'paste_remove_spans':'true',
        'paste_retain_style_properties':'text-decoration',
    }
    

    I get this issue when including either pre or post processing for paste, whether or not any of the other options for the paste plugin are included or not.

    opened by mattarchie 12
  • Trying to add new inlines just shows up as text areas. Could be similar to an earlier issue

    Trying to add new inlines just shows up as text areas. Could be similar to an earlier issue

    Trying to add new inlines just shows up as text areas, no TinyMCE in sight. Could be similar to an earlier issue, however it was closed years ago so perhaps this is a new one.

    I've put a project on Github so all settings etc. can be seen: https://github.com/jonashagstedt/tinymceissue

    Versions:

    • Django==1.6.2
    • django-tinymce==1.5.2
    bug 
    opened by hagsteel 12
  • Deprecation Warnings In Browser Inspect

    Deprecation Warnings In Browser Inspect

    tinymce.min.js:9 The following deprecated features are currently enabled, these will be removed in TinyMCE 6.0. See https://www.tiny.cloud/docs/release-notes/6.0-upcoming-changes/ for more information.

    Plugins:

    • contextmenu
    • spellchecker
    • textcolor

    Settings:

    • elements
    • force_p_newlines
    • mode
    opened by some1ataplace 6
  • django-tinymce with django-bootstrap-modal-forms

    django-tinymce with django-bootstrap-modal-forms

    I had some problems getting the TinyMCE editor to work in a bootstrap modal. The way I got it to work was to load this in the base view:

    <script src="{% static 'tinymce/tinymce.min.js' %}"></script>
    

    and these in the modal view:

    <script src="{% static 'django_tinymce/init_tinymce.js' %}"></script>
    <link rel="stylesheet" type="text/css" id="mce-u0" href="{% static 'tinymce/skins/ui/oxide/skin.min.css' %}">
    

    I also needed to edit the initTinyMCE() function in django_tinymce/init_tinymce.js to first remove any existing tinymce instance:

    ...
    const id = el.id;
    if (tinyMCE.get(id)) {
        tinyMCE.remove('#' + id);
    }
    if ('elements' in mce_conf && mce_conf['mode'] == 'exact') {
        mce_conf['elements'] = id;
    }
    if (el.dataset.mceGzConf) {
        tinyMCE_GZ.init(JSON.parse(el.dataset.mceGzConf));
    }
    if (!tinyMCE.get(id)) {
        tinyMCE.init(mce_conf);
    }
    ...
    

    If the modal was closed and reopened, the tinymce textarea would not work without first removing the existing instance.

    If someone knows a better way, please let me know.

    opened by teelei 0
  • Any way to enable dark mode detection?

    Any way to enable dark mode detection?

    I saw on this document that there is a way to detect dark mode in javascript and apply a specific skin and content_css. https://www.tiny.cloud/blog/dark-mode-tinymce-rich-text-editor/

    skin: (window.matchMedia("(prefers-color-scheme: dark)").matches ? "oxide-dark" : ""),
    content_css: (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "")
    

    I'm not sure how to do it as part of this package since it only takes a dict and doesn't seem to process the values client-side. Is there some easy pattern I'm missing or maybe just a way to have it pass these dark mode detection values to the init?

    opened by jonespm 2
  • Add MathJax plugin

    Add MathJax plugin

    I have this working for me and wanted to add it in. It is a modified version of https://github.com/dimakorotkov/tinymce-mathjax that enables inline and display modes. I have the mathjax library bundled in so it doesn't depend upon a CDN to work. Please let me know if you have any questions.

    opened by erdos4d 1
Releases(3.5.0)
Owner
Jazzband
We are all part of this
Jazzband
Silk is a live profiling and inspection tool for the Django framework.

Silk is a live profiling and inspection tool for the Django framework. Silk intercepts and stores HTTP requests and database queries before presenting them in a user interface for further inspection:

Jazzband 3.7k Jan 02, 2023
Simpliest django(uvicorn)+postgresql+nginx docker-compose (ready for production and dev)

simpliest django(uvicorn)+postgresql+nginx docker-compose (ready for production and dev) To run in production: docker-compose up -d Site available on

Artyom Lisovskii 1 Dec 16, 2021
Let AngularJS play well with Django

django-angular Let Django play well with AngularJS What does it offer? Add AngularJS directives to Django Forms. This allows to handle client side for

Jacob Rief 1.2k Dec 27, 2022
A debug/profiling overlay for Django

Django Debug Toolbar The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/respons

David Cramer 228 Oct 17, 2022
demo project for django channels tutorial

django_channels_chat_official_tutorial demo project for django channels tutorial code from tutorial page: https://channels.readthedocs.io/en/stable/tu

lightsong 1 Oct 22, 2021
Django API creation with signed requests utilizing forms for validation.

django-formapi Create JSON API:s with HMAC authentication and Django form-validation. Version compatibility See Travis-CI page for actual test results

5 Monkeys 34 Apr 04, 2022
TinyApp - A Python (Django) Full Stack Application for shortening URLs

TinyApp A Python (Django) Full Stack Application for shortening URLs. How to sta

Li Deng 1 Jan 23, 2022
Django Simple Spam Blocker is blocking spam by regular expression.

Django Simple Spam Blocker is blocking spam by regular expression.

Masahiko Okada 23 Nov 29, 2022
Comparing Database performance with Django ORM

Comparing Database performance with Django ORM Postgresql MySQL MariaDB SQLite Comparing database operation performance using django ORM. PostgreSQL v

Sarath ak 21 Nov 14, 2022
Modular search for Django

Haystack Author: Daniel Lindsley Date: 2013/07/28 Haystack provides modular search for Django. It features a unified, familiar API that allows you to

Haystack Search 3.4k Jan 08, 2023
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 167 Nov 10, 2022
Strawberry-django-plus - Enhanced Strawberry GraphQL integration with Django

strawberry-django-plus Enhanced Strawberry integration with Django. Built on top

BLB Ventures 138 Dec 28, 2022
The friendly PIL fork (Python Imaging Library)

Pillow Python Imaging Library (Fork) Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lund

Pillow 10.4k Jan 03, 2023
Django datatables and widgets, both AJAX and traditional. Display-only ModelForms.

Django datatables and widgets, both AJAX and traditional. Display-only ModelForms. ModelForms / inline formsets with AJAX submit and validation. Works with Django templates.

Dmitriy Sintsov 132 Dec 14, 2022
Notes-Django: an advanced project to save notes in Django. where users are able to Create, Read, Update and Delete their notes.

An advanced software to keep you notes. It allows users to perform CRUD operations on theirs Notes. Was implemented Authorization and Authentication

Edilson Pateguana 1 Feb 05, 2022
Zendesk Assignment - Django Based Ticket Viewer

Zendesk-Coding-Challenge Django Based Ticket Viewer The assignment has been made using Django. Important methods have been scripted in views.py. Excep

Akash Sampurnanand Pandey 0 Dec 23, 2021
Pinax is an open-source platform built on the Django Web Framework.

Symposion Pinax Pinax is an open-source platform built on the Django Web Framework. It is an ecosystem of reusable Django apps, themes, and starter pr

Pinax Project 295 Mar 20, 2022
Coltrane - A simple content site framework that harnesses the power of Django without the hassle.

coltrane A simple content site framework that harnesses the power of Django without the hassle. Features Can be a standalone static site or added to I

Adam Hill 58 Jan 02, 2023
Django Girls Tutorial Workshop

Django Girls Tutorial Workshop A log of activities during the workshop. this is an H2 git remote add origin https://github.com/ahuimanu/django_girls_t

Jeffry Babb 1 Oct 27, 2021
Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot. A fully Django starter project.

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot 🚀 Features A Django stater project with fully basic requirements for a production-ready

8 Jun 27, 2022