romanvm / django-tinymce4-lite Goto Github PK
View Code? Open in Web Editor NEWTinyMCE 4 editor widget for Django
License: MIT License
TinyMCE 4 editor widget for Django
License: MIT License
Hi,
Today I've upgraded django-filebrowser (3.13.1), django-tinymce4-lite (1.8.0) and Django (to version 3.0) and when I try to open the filebrowser from tinymce, the browser (tested with Firefox and Chrome) denies it with this message.
Now, using filebrowser from Django admin this problems is not present.
EDIT1: tested only in development environment with DEBUG enabled, not in production for obvious reasons.
EDIT2: adding X_FRAME_OPTIONS = 'SAMEORIGIN' to settings.py solved the problem for now.
Any ideas, or what I am missing? Thanks.
Hi guys, not sure if is bug or not but I think it should be mentioned. Pip complains to upgrade the package from 1.6.0 or 1.7.0 to 1.8.0 in Python 2.7 and the latest Django version for that, 1.11.8.
Pip is using the latest version of Django that has in the pool which is 2.0 as cached and thus fails the upgrade.
To solve the issue I needed to manually install the package without upgrade
pip install django-tinymce4-lite==1.7.0
Here is the error report
pip install django-tinymce4-lite -U
Collecting Django>=1.8.0 (from django-tinymce4-lite)
Using cached Django-2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-cN4rKg/Django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
@functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
Hi,
I ran into a problem where I can't add callback functions to the default config because it always returns with an error:
Uncaught TypeError: d.call is not a function
at k.b (theme.min.js:4)
at c.i [as fire] (tinymce.min.js:8)
at k.fire (theme.min.js:2)
at k.<anonymous> (theme.min.js:3)
at c.i [as fire] (tinymce.min.js:8)
at k.fire (theme.min.js:2)
at HTMLDivElement.c (theme.min.js:1)
at m (tinymce.min.js:2)
at HTMLDivElement.y (tinymce.min.js:2)
b @ theme.min.js:4
i @ tinymce.min.js:8
fire @ theme.min.js:2
(anonymous) @ theme.min.js:3
i @ tinymce.min.js:8
fire @ theme.min.js:2
c @ theme.min.js:1
m @ tinymce.min.js:2
y @ tinymce.min.js:2
The callback function is defined as a string, and it looks like TInymce treats it as a string rather than a function which causes the problem. Am I doing something wrong?
Looks like the same issue has been fixed in django-tinyme before: jazzband/django-tinymce#152 I'm not sure if the same thing is happening here or not.
Hi,
in development env, the text fields are formatted as expected.
But on production, the textfileds has the blank html and the menubar is not shown
Hey, say I want to add the class browser-default
to all ul
elements. How would I do that? I am just using content = HTMLField('Content')
in my models.py.
When ManifestStaticFilesStorage
is used as a storage class for static files, running any Django management command with collectstatic
DEBUG = False
causes ValueError
exception because staticfiles_storage.url()
tries to get hash-versioned filename from manifest.json
that is not there yet. Current workaround is to temporarily switch to DEBUG = True
and run collectstatic
but it is not a good idea to manipulate with DEBUG
in production. A solution is needed that both allows to run collectstatic
with DEBUG = False
and retains serving hash-versioned static assets from tinymce4-lite
.
Hey! Trying to get this to work through the widget decleration on a form field and it's not rendering at all. Any advice on how to resolve?
I wanted to add tinymce in my admin forms without having to change the model and implementing it like this:
from tinymce.widgets import TinyMCE
from django.db import models
class EventAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {'widget': TinyMCE(attrs={'cols': 10, 'rows': 30})},
}
admin.site.register(Event, EventAdmin)
works but the attributes are overwritten with the ones from my settings.py file.
Is there a way to use this with formfield_overrides or do I have to change all my model fields?
Hi!)
I tried to install your plugin, but when I try to run "python manage.py makemigrations" python raise an error:
I use python 3.5 and django 1.9.6.
traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute django.setup() File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 662, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/tinymce/__init__.py", line 14, in <module> from .models import HTMLField File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/tinymce/models.py", line 8, in <module> from tinymce.widgets import TinyMCE, AdminTinyMCE File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/tinymce/widgets.py", line 24, in <module> import enchant File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/enchant/__init__.py", line 92, in <module> from enchant import _enchant as _e File "/Users/silva/Documents/Sandbox/galaxy-droid-models-django/myenv/lib/python3.5/site-packages/enchant/_enchant.py", line 121, in <module> prefix_dir.contents = c_char_p(e_dir) TypeError: bytes or integer address expected instead of str instance (myenv) Vlads-MacBook-Pro:gdmodels silva$
I'm trying to change the initialization parameters for TinyMCE. In particular I'm trying to change the setup parameter so that I can run a command on change.
I've tried to add to TINYMCE_CALLBACKS but the format doesn't come out right.
"setup": "function(editor){editor.on('change',function(){editor.save();console.log('CHANGED');});}",
The default setup still exists and I cannot override it. I'm just wondering if I'm going about this the wrong way.
EDIT: Tried using TINYMCE_CALLBACKS
Any plan for supporting django 2.2 version since it's a LTS upto 2022 ?
I had a bug where a form field using HTMLField() wasn't submitting the changed value. I finally tracked it down to using form.serialize() to send form via ajax - this issue:
https://stackoverflow.com/q/2122085
The solution was to use tinyMCE.triggerSave();
before submitting. I realise this isn't an issue with django-tinymce4-lite but just wondering if it's worth noting in documentation? Or integrating solution from https://stackoverflow.com/a/24284938 to avoid the problem:
tinymce.init({
selector: "textarea",
setup: function (editor) {
editor.on('change', function () {
editor.save();
});
}
});
Hi, thank you for your hard work, I am having problems (web development is very new to me), but I can see that this is a very useful tool.
I have installed django-tinymce4-lite==1.7.0 along with django-filebrowser-no-grappelli==3.7.4. I am able to clearly see the TinyMCE browser to assist with formatting within the admin module, but any changes I make are then displayed with the HTML used. For example, I added bold to the first line of my test blog and I see the following on the page:
"
Also testing a different sized image. "
EDIT: added an image of what I can see as the above quote simply changed into how I expected to view it.
![image](https://user-images.githubusercontent.com/35370046/37342305-0d3e2374-26bc-11e8-9d78-8ffc08b92cd9.png)
I am using Django 2.0.2 and Python version 3.6.4. I'm not sure what I've missed?
One other quick question, I may be experiencing some issues with the media file location, but just to clarify, when trying to insert an image TinyMCE requests "Source", can I use django tags, i.e. {% static 'images/AnImage.png' %}?
Thanks in advance for your time.
Not sure if this is a bug, but I can't find anything about this anywhere. When using django-tinymce4-lite in combination with django-filebrowser-no-grappelli, everything seems to work great locally. In production, however, I get the following console error (in tinymce.min.js) upon trying to upload a new image in the insert/edit image modal:
Mixed Content: The page at 'https://...38/change/' was loaded over HTTPS, but requested an insecure resource 'http://localhost/admin/filebrowser/browse/?pop=4&type=image'. This request has been blocked; the content must be served over HTTPS.
TinyMCE seems to try to load the filebrowser from localhost? Did I miss a setting?
Hi,
By default, the admin widget width is hardcoded to 1024. Is there a way to make it fluid with regards to the width of the browser tab?
Best.
how to, please?
Hi,
Is there a way to remove/disable this errors in terninal when runing python manage.py runserver?:
I only added English and Spanish dicts in Tinymce settings ('spellchecker_languages': 'English=en_US,Spanish=es').
Thanks.
how can i change color of text area in django-tinymce-4-lite?
i have tiny-mice options in my setting.py file
TINYMCE_DEFAULT_CONFIG = {
# 'width': "auto",
# 'height': "500",
# 'selector': "textarea",
# 'theme': "modern",
# 'paste_data_images': True,
# 'plugins': [
# "advlist autolink lists link image charmap print preview hr anchor pagebreak",
# "searchreplace wordcount visualblocks visualchars code fullscreen",
# "insertdatetime media nonbreaking save table contextmenu directionality",
# "emoticons template paste textcolor colorpicker textpattern"
# ],
# 'toolbar1': "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
# 'toolbar2': "print preview media | forecolor backcolor emoticons",
# 'image_advtab': True,
'width': "auto",
'height': "350",
'selector': "textarea",
'theme': "modern",
'paste_data_images': True,
'plugins': [
"advlist autolink lists link charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor colorpicker textpattern"
],
'toolbar1': "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link ",
'toolbar2': "print preview media | forecolor backcolor emoticons",
'image_advtab': True,
}
thanks
I can't find a way to auto resize the width of the text area in the form. I was able to fit it to the form but it will ruin the design for devices with smaller screen.
Hi,
I'm installing django-tinymce4-lite and am getting the following error:
error: [Errno 2] No such file or directory: '/tmp/easy_install-fntzp9h3/django-tinymce4-lite-1.5.2/docs/changelog.rst'
An error occurred when trying to install /tmp/tmp68dxjptnget_dist/django-tinymce4-lite-1.5.2.tar.gz. Look above this message for any errors that were output by easy_install.
While:
Installing python.
Getting distribution for 'django-tinymce4-lite'.
Due to the following code in setup.py:
Line 19 in 94982b0
The docs directory is missing from the .tar.gz.
Hi,
The default config puts bullist
and numlist
in the first toolbar, but omits to include the lists
plugin. So the correspond icons don't appear.
Marc.
Hi everyone, I am using django 1.11, django-tinymce4-lite 1.7.4.
### This problem only occurs in internet explorer 11.
ManifestStaticFilesStorage
is a subclass of the StaticFilesStorage
storage backend which stores the file names it handles by appending the MD5 hash of the file’s content to the filename. For example, the file js/tinymce.min.js
would also be saved as js/tinymce.min.500c07cb726a.js
.
If I switch my storage to StaticFilesStorage
it works fine.
Has anyone come across that yet? Or a suggestion how that can be solved (with ManifestStaticFilesStorage
to keep)
Hello,
I'm using version 1.7.3 in a website that uses django's built in translation system to allow users to choose a language. When first loading a webpage using my own account, set to English, the TinyMCE editor loads in English. If I then change my account language to Spanish and reload a page with the editor, the editor remains in English until I restart the server. After restarting, the language again matches mine on first page view - Spanish - but remains so even after changing my preferred language, until the next time the server reboots.
I'm creating the TinyMCE widget by defining a field in my models.py:
from tinymce import HTMLField
description = HTMLField(verbose_name=_('Description'))
My form is a simple ModelForm, which does not to anything to self.fields['description']
.
Spanish interface, English TinyMCE:
The following code in my form fixed the problem, by forcing the get_language call in TinyMCE.init to run in the context of the current request, instead of being saved from the first request after the server last starter:
class EventForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['description'].widget = TinyMCE()
Is this something that can be fixed in django-tinymce4-lite to avoid needing to make this patch in each form that uses it?
Hi there!
I updated my CSP settings and suddenly the plugin stopped working. I read at the TinyMCE website (https://www.tiny.cloud/docs/advanced/security/#qhowdoisetupcontentsecuritypolicycspwithtinymce) that the unsafe-inline
is NOT required. When I enable it in my django project, the editor is not shown. Analysing it with Firebug shows inline scripts as well.
Any ideas if this is going to be fixed at some point or if I'm doing something wrong?
Thanks!
Rony
When I installed django-tinymce4-lite with filebrowser no grapelli, it returns Type error n is not a function.
You can check out the project here
https://github.com/YiiKuoChong/yiikuochong-site
zm/c.fire
http://127.0.0.1:8000/static/tinymce/js/tinymce/tinymce.min.js:2:182881
fire
http://127.0.0.1:8000/static/tinymce/js/tinymce/themes/modern/theme.min.js:1:31285
init/<
http://127.0.0.1:8000/static/tinymce/js/tinymce/themes/modern/theme.min.js:1:70370
zm/c.fire
http://127.0.0.1:8000/static/tinymce/js/tinymce/tinymce.min.js:2:182881
fire
http://127.0.0.1:8000/static/tinymce/js/tinymce/themes/modern/theme.min.js:1:31285
o
http://127.0.0.1:8000/static/tinymce/js/tinymce/themes/modern/theme.min.js:1:35500
C
http://127.0.0.1:8000/static/tinymce/js/tinymce/tinymce.min.js:2:12511
d
http://127.0.0.1:8000/static/tinymce/js/tinymce/tinymce.min.js:2:12662```
after clicking "add another" for django admin inlines, the tinymce interface is not initialized
Hi,
Is there a reason why the language is truncated in get_language_config
(https://github.com/romanvm/django-tinymce4-lite/blob/master/tinymce/widgets.py#L41) rather than passed through convert_language_code
?
For example, for fr-fr
, I should get fr_FR
and not fr
. The workarounds I currently have is to set the language settings in TINYMCE_DEFAULT_CONFIG
, but that shouldn't be needed (even more if I want to have a multilingual app).
Thanks
Hi,
Just moved from django-tinymce
to django-tinymce4-lite
because I need version TinyMCE V4. I'm seeing this error when loading a page in Django Admin. It looks like this tool depends on enchant
, but doesn't explicitly list in as a dependency (hence the bug).
Full Stack Trace:
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request)
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _legacy_get_response 249. response = self._get_response(request)
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in wrapper 551. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/sites.py" in inner 224. return view(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in change_view 1511. return self.changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper 67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func 63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in changeform_view 1408. return self._changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in _changeform_view 1437. ModelForm = self.get_form(request, obj)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in get_form 615. fields = flatten_fieldsets(self.get_fieldsets(request, obj))
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in get_fieldsets 304. return [(None, {'fields': self.get_fields(request, obj)})]
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in get_fields 604. form = self.get_form(request, obj, fields=None)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in get_form 647. return modelform_factory(self.model, **defaults)
File "/usr/local/lib/python3.4/site-packages/django/forms/models.py" in modelform_factory 546. return type(form)(class_name, (form,), form_class_attrs)
File "/usr/local/lib/python3.4/site-packages/django/forms/models.py" in __new__ 252. opts.field_classes)
File "/usr/local/lib/python3.4/site-packages/django/forms/models.py" in fields_for_model 170. formfield = formfield_callback(f, **kwargs)
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/options.py" in formfield_for_dbfield 178. return db_field.formfield(**kwargs)
File "/usr/local/lib/python3.4/site-packages/tinymce/models.py" in formfield 33. 'widget': TinyMCE(profile=self.tinymce_profile)
File "/usr/local/lib/python3.4/site-packages/tinymce/widgets.py" in __init__ 148. self.profile = get_language_config()
File "/usr/local/lib/python3.4/site-packages/tinymce/widgets.py" in get_language_config 69. from enchant import list_languages
Must be something obvious. Trying to use Tinymce on non-admin page forms.
Did the setup type steps. I don't see any JS or such being installed. So fine, downloaded my own tinymce.js. Include it in path. Init doesn't seem to be called.
At the point of downloading my only tinymce.js and calling init myself, what is the plugin doing for me?
I also noticed that {{ form.media }}
has no output, so perhaps that is part of the problem?
On Django 1.11...
What am I missing?
Question is in the title :)
I'm using django-tinymce4-lite HTMLField
in a model of my project. This seems to trigger weird errors when using django management commands. The bottom of the stack trace looks like this:
File "/home/user/git/djangotest/profiles/urls.py", line 3, in <module>
from .views import guest, host
File "/home/user/git/djangotest/profiles/views/guest.py", line 20, in <module>
import profiles.forms.common as common_forms
File "/home/user/git/djangotest/profiles/forms/common.py", line 13, in <module>
class MotivationResumeForm(BaseModelForm):
File "/home/user/git/djangotest/pyenv/lib/python3.4/site-packages/django/forms/models.py", line 247, in __new__
opts.field_classes)
File "/home/user/git/djangotest/pyenv/lib/python3.4/site-packages/django/forms/models.py", line 172, in fields_for_model
formfield = f.formfield(**kwargs)
File "/home/user/git/djangotest/pyenv/lib/python3.4/site-packages/tinymce/models.py", line 33, in formfield
'widget': TinyMCE(profile=self.tinymce_profile)
File "/home/user/git/djangotest/pyenv/lib/python3.4/site-packages/tinymce/widgets.py", line 124, in __init__
self.profile = get_language_config()
File "/home/user/git/djangotest/pyenv/lib/python3.4/site-packages/tinymce/widgets.py", line 40, in get_language_config
config = {'language': get_language()[:2]}
TypeError: 'NoneType' object is not subscriptable
I tried setting LANGUAGES
in my django settings file, but the problem won't go away. Is get_language()
handled properly in all cases? There was a change in how the function behaves in Django 1.8, which might be related.
django.utils.translation.get_language() now returns None instead of
LANGUAGE_CODE
when translations are temporarily deactivated.
The problem doesn't appear when I actually run my project in the development server. Only maintenance commands (migrate
, reset_db
etc) seem to be affected.
Hello! I wanted to define a block_formats
option with translated menu labels, so I used gettext_lazy as is usual.
Traceback:
File lib/python3.7/site-packages/tinymce/widgets.py", line 140, in render_tinymce_init_js
'tinymce_config': json.dumps(mce_config)[1:-1],
File "lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "lib/python3.7/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
File "lib/python3.7/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
File "lib/python3.7/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
Solution: call json.dumps with this encoder class: https://docs.djangoproject.com/en/2.1/topics/serialization/#djangojsonencoder
Currently integration with django-filebrowser
is partially broken. In image select dialog you can only select a full-sized image but not its resized variants. JS console in a browser shows numerous errors. It looks like compatibility was broken at some point.
I've followed all the page instructions to display the Widget on my Admin form.
After running the server, I try to add a new model form and I get this error:
Reverse for 'tinymce-css' not found. 'tinymce-css' is not a valid view function or pattern name.
I'm running Django 3.0.4 w/ Bootstrap CSS. Isn't it supported?
If not, is there any workaround or related app to use instead?
Thanks.
Hi there--
My application is setup to work with django-tinymce4-lite and it works great when using local media storage. What i mean by that is if I choose to upload an image, the image gets uploaded to media/uploads
, including several thumbnail 'versions' that get saved to media/_versions
.
When I enable s3 as my media storage location, the image files are getting uploaded to the uploads
folder correctly (folder is auto created at upload time), however thumbnails are not generated alongside, and in fact, after an upload, the _versions
folder does not get created at all.
While I'm able to insert these images after upload using the image insert button, it's a bit frustrating in that unless the image has a descriptive filename, its impossible to tell which image is which without that image preview.
Here are the relevant settings regarding tinymce and s3 configuration:
# Media config
USE_S3 = int(os.environ.get('USE_S3', 0))
if USE_S3:
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_KEY')
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
AWS_DEFAULT_ACL = 'public-read'
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
AWS_PRELOAD_METADATA = True
AWS_QUERYSTRING_AUTH = False
# s3 media config
MEDIA_LOCATION = 'media'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIA_LOCATION}/'
DEFAULT_FILE_STORAGE = 'config.storage_backends.MediaStorage'
else:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# TinyMCE-lite config
TINYMCE_DEFAULT_CONFIG = {
'selector': 'textarea',
'theme': 'modern',
'plugins': 'link image preview codesample contextmenu table code lists colorpicker textcolor',
'toolbar1': 'formatselect | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignjustify '
'| bullist numlist | outdent indent | table | link image | codesample | preview code | fontsizeselect fontsize ',
'content_css': 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css',
'contextmenu': 'formats | link image',
'menubar': False,
'inline': False,
'statusbar': True,
'width': 'auto',
'height': 360,
}
Here is storage_backends.py
:
from storages.backends.s3boto3 import S3Boto3Storage
from django.conf import settings
from django.utils import timezone
class MediaStorage(S3Boto3Storage):
location = settings.MEDIA_LOCATION
default_acl = 'private'
file_overwrite = False
#custom_domain = False
isfilecached = {}
def isdir(self, name):
if not name: # Empty name is a directory
return True
if self.isfile(name):
return False
return True
def isfile(self, name):
if len(name.split('.')) > 1:
return True
try:
name = self._normalize_name(self._clean_name(name))
if self.isfilecached.get(name) is not None:
return self.isfilecached.get(name)
f = S3Boto3StorageFile(name, 'rb', self)
if "directory" in f.obj.content_type:
isfile = False
else:
isfile = True
except Exception:
isfile = False
self.isfilecached[name] = isfile
return isfile
def move(self, old_file_name, new_file_name, allow_overwrite=False):
if self.exists(new_file_name):
if allow_overwrite:
self.delete(new_file_name)
else:
raise "The destination file '%s' exists and allow_overwrite is False" % new_file_name
old_key_name = self._encode_name(self._normalize_name(self._clean_name(old_file_name)))
new_key_name = self._encode_name(self._normalize_name(self._clean_name(new_file_name)))
k = self.bucket.meta.client.copy(
{
'Bucket': self.bucket.name,
'Key': new_key_name
},
self.bucket.name,
old_key_name
)
if not k:
raise "Couldn't copy '%s' to '%s'" % (old_file_name, new_file_name)
self.delete(old_file_name)
def makedirs(self, name):
name = self._normalize_name(self._clean_name(name))
return self.bucket.meta.client.put_object(Bucket=self.bucket.name, Key=f'{name}/')
def rmtree(self, name):
name = self._normalize_name(self._clean_name(name))
delete_objects = [{'Key': f"{name}/"}]
dirlist = self.listdir(self._encode_name(name))
for item in dirlist:
for obj in item:
obj_name = f"{name}/{obj}"
if self.isdir(obj_name):
obj_name = f"{obj_name}/"
delete_objects.append({'Key': obj_name})
self.bucket.delete_objects(Delete={'Objects': delete_objects})
def path(self, name):
return name
def listdir(self, name):
directories, files = super().listdir(name)
if '.' in files:
files.remove('.')
return directories, files
def exists(self, name):
if self.isdir(name):
return True
else:
return super().exists(name)
def get_modified_time(self, name):
try:
# S3 boto3 library requires that directorys have the trailing slash
if self.isdir(name):
name = f'{name}/'
modified_date = super().get_modified_time(name)
except Exception:
modified_date = timezone.now()
return modified_date
def size(self, name):
try:
# S3 boto3 library requires that directorys have the trailing slash
if self.isdir(name):
name = f'{name}/'
size = super().size(name)
except Exception:
size = 0
return size
Hello.
I've first installed django-tinymce package with pip, for my django, configured it, and it worked properly. Then I figured it's missing paragraphs UI, and found out about django-tinymce4-lite package. Now, since you're using the same tinymce
module name, I simply uninstalled django-tinymce, and installed django-tinymce4-lite with pip, restarted servers(both gunicorn and nginx), ran collectstatic, and I'm still getting the old version of tinymce.
What could I be doing wrong?
Hi,
Is there a way to setup mutiple settings? Leys say I want one tinyce settings (specially, the toolbar) for the admin section of my site and another for the public section (users).
Thanks.
Hey I'm currently trying to install django-tinymce4-lite but keep getting caught at trying to include the tinymce.urls. Using django 2.0.5, python 3.6.5. I've double checked that it is installed by pip freeze and it says django-tinymce4-lite==1.7.1 is installed.
Here's the error message:
Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute self.check() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks return checks.run_checks(**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 397, in check for pattern in self.url_patterns: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 536, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 529, in urlconf_module return import_module(self.urlconf_name) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/ryan/Documents/Dev/metalroofingonline/src/ecommerce/urls.py", line 103, in <module> url(r'^tinymce/', include('tinymce.urls')), File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'tinymce.urls'
Any help would be great, thanks.
Hello, the language file resolving does not work well for us when changing django language to french ('fr').
Failed to load: http://localhost:8000/static/tinymce/js/tinymce/langs/fr.js
What exists in the codebase is fr_FR.js but from code i think this will never be resolved or is there any configuration parameter that i missed?
Language config from settings:
LANGUAGE_CODE = 'en'
LANGUAGES = [
('en', _('English')),
('fr', _('French')),
('de', _('German')),
]
My TinyMCE default config:
TINYMCE_DEFAULT_CONFIG = {
'selector': 'textarea',
'theme': 'modern',
'plugins': 'link image preview codesample contextmenu table code',
'toolbar1': 'bold italic underline | alignleft aligncenter alignright alignjustify '
'| bullist numlist | outdent indent | table | link | codesample | preview code',
'contextmenu': 'formats | link',
'menubar': False,
'inline': False,
'statusbar': True,
'height': 360,
}
Thanks much!
Dear developers. U wrote two string, whose break down app in production on 32bit machine. Why u override logger config? Config must override in settings.py, and not in widgets.py and views.py. Proggrammer what wrote this, is bad guy. Im tired
Hi, when i insert a script tag inside the tiny mce editor in django admin, the script tags are stripped. i tried the following setting but doesnt work.
TINYMCE_DEFAULT_CONFIG = { 'selector': 'textarea', 'theme': 'modern', 'plugins': 'link image preview codesample contextmenu table code', 'toolbar1': 'bold italic underline | alignleft aligncenter alignright alignjustify ' '| bullist numlist | outdent indent | table | link image | codesample | preview code', 'contextmenu': 'formats | link image', 'menubar': False, 'inline': False, 'statusbar': True, 'height': 360, 'schema': 'html5', 'allow_script_urls': True, 'extended_valid_elements': 'script[charset|defer|async|language|src|type],iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],', }
Hi,
I am testing the latest stable version of django-tinymce4-lite (switched from django-ckeditor because is not working on ajax calls) and I wonder if there is a way to customize the toolbar in settings.py (like django-ckeditor) or another place.
django-tinymce4-lite: v1.4.2
django: v1.11.4
Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.