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
Django Login Api With Python

How to run this project Download and extract this project Create an environment and install all the libraries from requiements.txt pip freeze -r requi

Vikash Kisku 1 Dec 10, 2021
Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Intellicards-backend - A Django project bootstrapped with django-admin startproject mysite

Fabrizio Torrico 2 Jan 13, 2022
Learn Python and the Django Framework by building a e-commerce website

The Django-Ecommerce is an open-source project initiative and tutorial series built with Python and the Django Framework.

Very Academy 275 Jan 08, 2023
Developer-friendly asynchrony for Django

Django Channels Channels augments Django to bring WebSocket, long-poll HTTP, task offloading and other async support to your code, using familiar Djan

Django 5.5k Dec 29, 2022
Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

1 Dec 09, 2021
Simple reproduction of connection leak with celery/django/gevent

Redis connection leak with celery/django/gevent Reproduces celery issue at https://github.com/celery/celery/issues/6819 using gevented django web serv

2 Apr 03, 2022
A Django app that creates automatic web UIs for Python scripts.

Wooey is a simple web interface to run command line Python scripts. Think of it as an easy way to get your scripts up on the web for routine data anal

Wooey 1.9k Jan 08, 2023
This is a repository for a web application developed with Django, built with Crowdbotics

assignment_32558 This is a repository for a web application developed with Django, built with Crowdbotics Table of Contents Project Structure Features

Crowdbotics 1 Dec 29, 2021
Simple application TodoList django with ReactJS

Django & React Django We basically follow the Django REST framework quickstart guide here. Create backend folder with a virtual Python environment: mk

Flavien HUGS 2 Aug 07, 2022
Quick example of a todo list application using Django and HTMX

django-htmx-todo-list Quick example of a todo list application using Django and HTMX Background Modified & expanded from https://github.com/jaredlockh

Jack Linke 54 Dec 10, 2022
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 01, 2023
This is a repository for collecting global custom management extensions for the Django Framework.

Django Extensions Django Extensions is a collection of custom extensions for the Django Framework. Getting Started The easiest way to figure out what

Django Extensions 6k Dec 26, 2022
Projeto Crud Django and Mongo

Projeto-Crud_Django_and_Mongo Configuração para rodar o projeto Download Project

Samuel Fernandes Oliveira 2 Jan 24, 2022
pdm-django: Django command shortcuts for PDM

pdm-django: Django command shortcuts for PDM A plugin that gives you command shortcuts for developing with PDM. pdm run python manage.py runserver -

Neutron Sync 2 Aug 11, 2022
A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.

django-versatileimagefield A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for creat

Jonathan Ellenberger 490 Dec 13, 2022
Simple web site for sharing your short stories and beautiful pictures

Story Contest Simple web site for sharing your short stories and beautiful pictures.(Cloud computing first assignment) Clouds The table below shows cl

Alireza Akhoundi 5 Jan 04, 2023
Neighbourhood - A python-django web app to help the residence of a given neighborhood know their surrounding better

Neighbourhood A python-django web app to help the residence of a given neighborh

Levy Omolo 4 Aug 25, 2022
Chatbot for ordering and tracking a Pizza.

Pizza Chatbot To start the app, follow the below steps: Clone the repo using the below command: git clone Shreya Shah 1 Jul 15, 2021

A Powerful HTML white space remover for Django

HTML Whitespace remover for Django Introduction : A powerful tool to optimize Django rendered templates Why use "django_stip_whitespace" ? Adds line b

3 Jan 01, 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