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 backed for PostgreSQL using Psycopg 3

A Django backend for PostgreSQL using Psycopg 2 The backend passes the entire Django test suite, but it needs a few modifications to Django and to i

Daniele Varrazzo 42 Dec 16, 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
scaffold django rest apis like a champion 🚀

dr_scaffold Scaffold django rest apis like a champion ⚡ . said no one before Overview This library will help you to scaffold full Restful API Resource

Abdenasser Elidrissi 133 Jan 05, 2023
A blog app powered by python-django

Django_BlogApp This is a blog app powered by python-django Features Add and delete blog post View someone else blog Can add comment to that blog And o

Manish Jalui 1 Sep 12, 2022
The little ASGI framework that shines. 🌟

✨ The little ASGI framework that shines. ✨ Documentation: https://www.starlette.io/ Community: https://discuss.encode.io/c/starlette Starlette Starlet

Encode 7.7k Dec 31, 2022
webfest Django project @innovaccer

inno-doctor webfest Django project @innovaccer setup guide create new directory for project clone the repo with url into the directory make sure pytho

Rohit sahu 6 Oct 28, 2022
A BitField extension for Django Models

django-bitfield Provides a BitField like class (using a BigIntegerField) for your Django models. (If you're upgrading from a version before 1.2 the AP

DISQUS 361 Dec 22, 2022
Full-featured django project start tool.

django-start-tool Introduction django-start-tool is a full-featured replacement for django-admin startproject which provides cli for creating the same

Georgy Gnezdilov 0 Aug 30, 2022
Full-text multi-table search application for Django. Easy to install and use, with good performance.

django-watson django-watson is a fast multi-model full-text search plugin for Django. It is easy to install and use, and provides high quality search

Dave Hall 1.1k Dec 22, 2022
A collection of models, views, middlewares, and forms to help secure a Django project.

Django-Security This package offers a number of models, views, middlewares and forms to facilitate security hardening of Django applications. Full doc

SD Elements 258 Jan 03, 2023
React.JS - Django Application Template

OTS React.JS - DJango Web Application (UNTESTED) This repository servers as a template for creating React.JS - Django Web Applications. Note that the

Darryl See Wei Shen 5 Aug 19, 2022
Bootstrap 3 integration with Django.

django-bootstrap3 Bootstrap 3 integration for Django. Goal The goal of this project is to seamlessly blend Django and Bootstrap 3. Want to use Bootstr

Zostera B.V. 2.3k Jan 02, 2023
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
An example of Django project with basic user functionality and account activation.

Simple Django Login and Registration An example of Django project with basic user functionality. Screenshots Log In Create an account Authorized page

Hussein Sarea 3 Oct 19, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

10.1k Jan 08, 2023
Social Media Network Focuses On Data Security And Being Community Driven Web App

privalise Social Media Network Focuses On Data Security And Being Community Driven Web App The Main Idea: We`ve seen social media web apps that focuse

Privalise 8 Jun 25, 2021
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App 💛 We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
A simple demonstration of integrating a sentiment analysis tool in a django project

sentiment-analysis A simple demonstration of integrating a sentiment analysis tool in a django project (watch the video .mp4) To run this project : pi

2 Oct 16, 2021
TinyMCE integration for Django

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

Jazzband 1.1k Dec 26, 2022
based official code from django channels, replace frontend with reactjs

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