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
Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery

Django GUID Now with ASGI support! Django GUID attaches a unique correlation ID/request ID to all your log outputs for every request. In other words,

snok 300 Dec 29, 2022
Django API without Django REST framework.

Django API without DRF This is a API project made with Django, and without Django REST framework. This project was done with: Python 3.9.8 Django 3.2.

Regis Santos 3 Jan 19, 2022
The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango.

The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango. It requires a django-leaflet package.

Vsevolod Novikov 33 Nov 11, 2022
Актуальный сборник шаблонов для создания проектов и приложений на Django

О чем этот проект Этот репозиторий с шаблонами для быстрого создания Django проекта. В шаблоне проекта настроены следующий технологий: Django gunicorn

Denis Kustov 16 Oct 20, 2022
Application made in Django to generate random passwords as based on certain criteria .

PASSWORD GENERATOR Welcome to Password Generator About The App Password Generator is an Open Source project brought to you by Iot Lab,KIIT and it brin

IoT Lab KIIT 3 Oct 21, 2021
Django-Text-to-HTML-converter - The simple Text to HTML Converter using Django framework

Django-Text-to-HTML-converter This is the simple Text to HTML Converter using Dj

Nikit Singh Kanyal 6 Oct 09, 2022
📊📈 Serves up Pandas dataframes via the Django REST Framework for use in client-side (i.e. d3.js) visualizations and offline analysis (e.g. Excel)

Django REST Pandas Django REST Framework + pandas = A Model-driven Visualization API Django REST Pandas (DRP) provides a simple way to generate and se

wq framework 1.2k Jan 01, 2023
Dynamic, database-driven Django forms

Django Dataforms django-dataforms is a wrapper for the Django forms API that lets you dynamically define forms in a database, rather than hard-coding

35 Dec 16, 2022
Resolve form field arguments dynamically when a form is instantiated

django-forms-dynamic Resolve form field arguments dynamically when a form is instantiated, not when it's declared. Tested against Django 2.2, 3.2 and

DabApps 108 Jan 03, 2023
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
An API was build with Django to store and retrieve information about various musical instruments.

The project is meant to be a starting point, an experimentation or a basic example of a way to develop an API with Django. It is an exercise on using Django and various python technologies and design

Kostas Ziovas 2 Dec 25, 2021
Source files for a free pyRevit toolbar.

pyRoovit (WIP) What is this? PyRoovit is/will be a toolbar for the use with pyRevit built by Gavin Crump (aka Aussie BIM Guru). Having used and taught

Gavin Crump 11 Nov 10, 2022
Django-powered application about blockchain (bitcoin)

Django-powered application about blockchain (bitcoin)

Igor Izvekov 0 Jun 23, 2022
Serve files with Django.

django-downloadview django-downloadview makes it easy to serve files with Django: you manage files with Django (permissions, filters, generation, ...)

Jazzband 328 Dec 07, 2022
A GitHub Action for checking Django migrations

🔍 Django migrations checker A GitHub Action for checking Django migrations About This repository contains a Github Action that checks Django migratio

Oda 5 Nov 15, 2022
An insecure login and registration website with Django.

An insecure login and registration website with Django.

Luis Quiñones Requelme 1 Dec 05, 2021
Improved Django model inheritance with automatic downcasting

Polymorphic Models for Django Django-polymorphic simplifies using inherited models in Django projects. When a query is made at the base model, the inh

1.4k Jan 03, 2023
A Blog Management System Built with django

Blog Management System Backend use: Django Features Enhanced Ui

Vishal Goswami 1 Dec 06, 2021
PostgreSQL with Docker + Portainer + pgAdmin + Django local

django-postgresql-docker Running PostgreSQL with Docker + Portainer + pgAdmin + Django local for development. This project was done with: Python 3.9.8

Regis Santos 4 Jun 12, 2022
Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Wanderson Fontes 2 Sep 21, 2022