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
A Django app for working with BTCPayServer

btcpay-django A Django app for working with BTCPayServer Installation pip install btcpay-django Developers Release To cut a release, run bumpversion,

Crawford 3 Nov 20, 2022
Logan is a toolkit for building standalone Django applications

Logan Logan is a toolkit for running standalone Django applications. It provides you with tools to create a CLI runner, manage settings, and the abili

David Cramer 206 Jan 03, 2023
Simple yet powerful and really extendable application for managing a blog within your Django Web site.

Django Blog Zinnia Simple yet powerful and really extendable application for managing a blog within your Django Web site. Zinnia has been made for pub

Julien Fache 2.1k Dec 24, 2022
Django With VueJS Blog App

django-blog-vue-app frontend Project setup yarn install Compiles and hot-reload

Flavien HUGS 2 Feb 04, 2022
A pickled object field for Django

django-picklefield About django-picklefield provides an implementation of a pickled object field. Such fields can contain any picklable objects. The i

Gintautas Miliauskas 167 Oct 18, 2022
Vehicle registration using Python, Django and SQlite3

PythonCrud Cadastro de veículos utilizando Python, Django e SQlite3 Para acessar o deploy no Heroku:

Jorge Thiago 4 May 20, 2022
Domain-driven e-commerce for Django

Domain-driven e-commerce for Django Oscar is an e-commerce framework for Django designed for building domain-driven sites. It is structured such that

Oscar 5.6k Jan 01, 2023
A django model and form field for normalised phone numbers using python-phonenumbers

django-phonenumber-field A Django library which interfaces with python-phonenumbers to validate, pretty print and convert phone numbers. python-phonen

Stefan Foulis 1.3k Dec 31, 2022
xsendfile etc wrapper

Django Sendfile This is a wrapper around web-server specific methods for sending files to web clients. This is useful when Django needs to check permi

John Montgomery 476 Dec 01, 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
💨 Fast, Async-ready, Openapi, type hints based framework for building APIs

Fast to learn, fast to code, fast to run Django Ninja - Fast Django REST Framework Django Ninja is a web framework for building APIs with Django and P

Vitaliy Kucheryaviy 3.8k Jan 01, 2023
Django/Jinja template indenter

DjHTML A pure-Python Django/Jinja template indenter without dependencies. DjHTML is a fully automatic template indenter that works with mixed HTML/CSS

Return to the Source 378 Jan 01, 2023
A real-time photo feed using Django and Pusher

BUILD A PHOTO FEED USING DJANGO Here, we will learn about building a photo feed using Django. This is similar to instagram, but a stripped off version

samuel ogundipe 4 Jan 01, 2020
Django-powered application about blockchain (bitcoin)

Django-powered application about blockchain (bitcoin)

Igor Izvekov 0 Jun 23, 2022
Automatically upgrade your Django projects.

django-upgrade Automatically upgrade your Django projects. Installation Use pip: python -m pip install django-upgrade Python 3.8 to 3.10 supported. Or

Adam Johnson 525 Dec 29, 2022
Django + NextJS + Tailwind Boilerplate

django + NextJS + Tailwind Boilerplate About A Django project boilerplate/templa

Shayan Debroy 3 Mar 11, 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
This Django app will be used to host Source.Python plugins, sub-plugins, and custom packages.

Source.Python Project Manager This Django app will be used to host Source.Python plugins, sub-plugins, and custom packages. Want to help develop this

2 Sep 24, 2022
Add a help desk or knowledge base to your Django project with only a few lines of boilerplate code.

This project is no longer maintained. If you are interested in taking over the project, email Zapier 487 Dec 06, 2022

A simple trivia quizzz web app made using django

Trivia Quizzz A simple trivia quizzz web app made using django Demo http://triviaquizzz.herokuapp.com/ & https://triviaquiz.redcrypt.xyz Features Goog

Rachit Khurana 2 Feb 10, 2022