froala / django-froala-editor Goto Github PK
View Code? Open in Web Editor NEWPackage to integrate Froala WYSIWYG HTML rich text editor with Django.
Home Page: https://froala.com/wysiwyg-editor
Package to integrate Froala WYSIWYG HTML rich text editor with Django.
Home Page: https://froala.com/wysiwyg-editor
I am using django-froala-editor to generate a signature and policy and these policy and signature both will be returned to my Front end which is build in Angular 5.
I am following this link to make it work in django but I am getting syntax error
Cannot Find reference 'S3' in 'init.py'
On the following line of code.
from floara-editor import S3
Please help.
I have a problem where I can't submit my form because my description textarea
is required
but hidden
in my form
. Any idea how I can solve this? I have no idea where style="display:none;"
is coming from. Any idea?
class CustomFroalaEditor(FroalaEditor):
def __init__(self, *args, **kwargs):
super(CustomFroalaEditor, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None, renderer=None):
html = super(FroalaEditor, self).render(name, value, attrs)
return mark_safe(html)
class NewBlaForm(forms.ModelForm):
description = forms.CharField(widget=CustomFroalaEditor(attrs={'id': 'nb__description-editor'}))
class Meta:
model = Bla
fields = ('description')
From the readme
from django import forms
from froala_editor.widgets import FroalaEditor
class PageForm(forms.ModelForm):
content = models.TextField(widget=FroalaEditor)
It's wrong its supposed to be
from django import forms
from froala_editor.widgets import FroalaEditor
class PageForm(forms.ModelForm):
content = forms.CharField(widget=FroalaEditor)
I noticed in the image upload view, there's a decorator for csrf_exempt. I admit I'm not anywhere near a django expert, but I was under the impression the csrf token was there as a way to block rogue form submissions? Or to ensure the form submission came from where you think it came from?
If the image upload is csrf exempt, I assume that means it doesn't need a csrf token to upload images? Assuming that's accurate, what's to stop someone from viewing the html source of my page, grabbing the froala image upload path setting and uploading some kind of harmful code to my image directory from their own form?
On 2.6.6 and 2.7.0, froala-django.css and froala-django.js are missing from repository, but FroalaEditor widget refers to them in _media() method
I have a model form:
class TeachersCourseProfileForm(forms.ModelForm):
text = forms.CharField(widget=FroalaEditor)
class Meta:
model = CourseOwner
fields = (... , 'text', ... )
when I display the form with widget set to Froala editor for the text field, then field.help_text comes back empty. If I remove the widget it contains the help_text that I specified in the model for that field. This seems like a bug to me. I think the models fields help_text should be preserved. This is my model:
class CourseOwner(TimeStampedModel):
"""
Relationship of Courses to Accounts through the Relationship of teaching.
"""
...
text = models.TextField(verbose_name='Text',
help_text='''Personenbeschreibung: was qualifiziert Dich für das Halten dieses
Kurses?''',
blank=True)
I've paid for Froala and generated a license key on the froala website.
I've inserted the key into my settings file using
`FROALA_EDITOR_OPTIONS = {
'KEY': 'MY_KEY_IS HERE',
}`
But I still see the message 'Unlicensed Froala editor' in admin.
While I want to copy an article from Microsoft Word including a lot of images embed in Word, the image can only be uploaded as blob
in Django's media root like the screenshot below.
And sometimes, this can only upload one image, not all images. Also, this action only works on Chrome, and Safari does not work.
And my version is below
The main codes is below
# settings.py
INSTALLED_APPS = [
...
'froala_editor',
...
]
...
MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.join(BASE_DIR, 'media'))
MEDIA_URL = '/media/'
STATIC_ROOT = os.environ.get('STATIC_ROOT', os.path.join(BASE_DIR, 'static'))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static_media"),
)
FROALA_EDITOR_PLUGINS = (
'align', 'char_counter', 'code_beautifier', 'code_view', 'colors', 'draggable', 'emoticons',
'entities', 'file', 'font_family', 'font_size', 'fullscreen', 'image_manager', 'image',
'inline_style',
'line_breaker', 'link', 'lists', 'paragraph_format', 'paragraph_style', 'quick_insert',
'quote', 'save', 'table',
'url', 'video'
)
# urls.py
urlpatterns = [
...
url(r'^froala_editor/', include('froala_editor.urls')),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# models.py
...
class Article(models.Model):
content = FroalaField(options={
'heightMin': 400
})
...
Editors upload files with names in cyrillic: Тест например.docx
These files are saved on server as ???? ????????.docx and can't be opened.
Can we rename them or translify?
I have a model with FroalaField() and I want to filter data by the field. Unfortunately the Model.objects.filter() doesnt have option to filter by field__contains. How do I search on the field?
Hi
Django Version: 1.7
Exception Type: TypeError
Exception Value:
unsupported operand type(s) for +: 'dict_items' and 'dict_items'
Exception Location: /usr/local/lib/python3.4/dist-packages/froala_editor/widgets.py in get_options, line 30
Python Executable: /usr/bin/python3.4
Python Version: 3.4.1
Solution of this issue is wrong.
It both appends froala to all text fields and not only to froala fields
and doesn't add any options
I do not know how to fix this. When I first format a text, everything works fine. I can add colors and tables and much more. But when I try to update and open the text in my form again, certain formating has disappeared. Can you please help me with this. The formating seems to be stored in the database, since everything shows in the Detail view, just when I reload my update form Things go wrong.
Do you have a Python version of https://gist.github.com/stefanneculai/deed108fad534d0db3ff handy anywhere?
I import froala and set for CharField.widget
But show CharField (<textarea>) again!
class PostForm(forms.ModelForm):
content = forms.CharField(widget=FroalaEditor),
class Meta:
model = models.Post
fields = ('text',)
In your README you have mentioned this is how we should use the key
FROALA_EDITOR_OPTIONS = { 'KEY': '<our key goes here>', # other options # ... }
but this doesn't work because Froala is expecting a lowercase 'key' instead of the uppercase 'KEY'. Either change the documentation or change the code on widgets.py etc to convert to lowercase always.
Dear authors,
I've just used django-froala-editor, of course I followed your tutorial and I met problem with upload and use image file function.
From interface, I uploaded a file and approximately appeared the error:
something went wrong. Please try again
And then, I checked the default folder for storing data: "uploads/froala_editor/images", I can see the file that uploaded.
Also, I check the log file and see that:
Not Found: /admin/article/article/add/uploads/froala_editor/images/btn-login_Lp5ADiP.png/change/
So I would like to ask you about the parameter that I can set to change the directory for load image, I mean from /admin/article/article/add/uploads/froala_editor/images/ to uploads/froala_editor/images
Second question, from TextEditor, I clicked "Insert Image" and see the button "Browse folder". I click this and see tab "Manage Image" but maybe this for server online, I could not mange it well.
So how can I change the content of the tab for suitable of my purpose.
I'm waiting for your feedback. :)
Thanks and best regards,
I am using django forms with FroalaEditor from froala_editor.widgets. The image uploading works fine when I upload it in my local server. But when I push the code to a Ec2 server instance and try uploading an image using the froala field, an Error pops, saying "Something went wrong please try again"
Its a 403 error.
When I looked in the network, the cookie in the request headers is generated
Cookie:csrftoken=*********************************************************************
but the csrfmiddlewaretoken in the formData is NULL.
Again it works fine when I try it in my local. When I host it on server, its causing this issue. Please help
When i use FroalaField to upload a image from local, the error occurs.
This editor looks really nice and I might even give it a shot at replacing TinyMCE 4 on a site. I'm wondering though, does django-froala-editor make it easy to upload images into the body field? I see that's an option in their demo, but that would be a pretty big requirement for me; easy image uploads.
When uploading images the uploaded image is saved to uploads/froala_editor/images but the image does not appear in the editor or the html. This happens in forms and admin.
Steps taken to install:
pip install django-froala-editor
url(r'^froala_editor/', include('froala_editor.urls')), added to urlpatterns
Form.py has charfield with the widget set to Froala (widget=FroalaEditor)
I remember using this app in my last project without any problem but this time, I get this error on my console. I could use the app in admin page, but when I try to use it outside using {{form.media}} I get the above error. Why is this occurring and how do I fix this? Is it me doing it wrong or new version of froala?(because I used this app without any problem last time, and I loved it)
Only what I can is attach language file to Meta:
class Media:
js = ("froala_editor/js/languages/ru.js")
but it will load before froala.min.js and fall to error
Hi! I'm using docker-compose with nginx
and when I try to add an image I see an error:
image.min.js:7 POST http://localhost/froala_editor/image_upload/ 404 (Not Found)
How to configure nginx
to avoid this error?
Hi, when i install with this command
pip install django-froala-editor
Collecting django-froala-editor
Installing collected packages: django-froala-editor
Successfully installed django-froala-editor-2.0.1
this version install 2.0.1 is incompatible with django 1.10.2, the only way install is dowload
for repository and put in my root folder,
but my question is why is not posible install with pip
pip install django-froala-editor==2.3.5
Collecting django-froala-editor==2.3.5
Could not find a version that satisfies the requirement django-froala-editor==2.3.5 (from versions: 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.8.7, 0.9.0, 1.2.1, 1.2.2, 1.2.3, 1.2.3.1, 1.2.3.2, 1.2.4, 1.2.4.1, 1.2.4.2, 1.2.5, 1.2.6, 1.2.7, 2.0.0rc3, 2.0.0rc3.post1, 2.0.1)
thank any help
how to insert html
Please change keyword argument "mimetype" to "content_type" when creating an HTTPResponse object in froala_editor/views.py.
This works out for me.
Wasn't sure if you are getting notifications on closed issues, so I thought I'd open a new ticket. This is in relation to this issue: #5
After updating, image upload only works when I add the csrf_exempt decorator back to the view. Otherwise, I get a 403 error in terminal when trying to upload images. Any ideas?
Hello all,
I am trying to integrate Froala editor within django admin. I understood from the doc that the process is pretty straight forward.
I followed the getting started and usage part of the documentation here https://github.com/froala/django-froala-editor.
I created in my model.py :
from froala_editor.fields import FroalaField
from django.db import models
class Service(models.Model):
message = FroalaField()
When I log in the admin interface, the field shows as a textarea.
Do you have any idea why ? Am I doing something wrong?
Many thanks,
A picture is worth a thousand words :)
The reason for the first issue is this CSS part (from forms.css):
.form-row {
overflow: hidden;
padding: 10px;
font-size: 13px;
border-bottom: 1px solid #eee;
}
The reason for the second issue this CSS part (from forms.css):
.aligned label:not(.vCheckboxLabel):after {
content: '';
display: inline-block;
vertical-align: middle;
height: 26px;
}
I temporarily fixed those issues with a custom CSS added to the admin:
div.form-row {
overflow: visible;
}
.aligned label:not(.vCheckboxLabel):after {
content: none;
}
I can prepare a pull request with this fix if you'd like. I'm not sure what other (unwanted) effects could the overflow:visible
have though.
I tested this with Django 1.11.4 and 1.11.9 and django-froala-editor 2.7.3.
Hello,
I was just trying out Froala (don't have a license at the moment).
Documentation at this time has no references about setting it up on Django 1.10.x (maybe I'm missing something?). In order to get it working, file lib/python2.7/site-packages/froala_editor/urls.py
should be modified as follows:
from django.conf.urls import url
from froala_editor import views
urlpatterns = [
url(r'^image_upload/$', views.image_upload, name='froala_editor_image_upload'),
url(r'^file_upload/$', views.file_upload, name='froala_editor_file_upload'),
]
patterns() has been deprecated since Django 1.8
We have several froala editors on the same page where we need to set the maxCharacters option dynamically for each one.
Since all the editors are on the same Model the options instance used in the model is used for each editor. This means that when we set the value dynamically all the editors get the same value.
Heres some code showing what we do:
forms[x].fields['foo'].widget.options['maxCharacters'] = bar.maxchars
A workaround is to use copy on widget.options before settings the value like so:
forms[x].fields['foo'].widget.options = copy(forms[x].fields['foo'].widget.options)
forms[x].fields['foo'].widget.options['maxCharacters'] = bar.maxchars
I think it would be cleaner if that was done in django-froala-editor.
The image link doesn't exist in the editor content The bug appears in versions 2.1.0+.
Install the latest django-froala-editor
version.
Install the django-froala-editor
version 2.0.1.
(using virtualenvwrapper to ease the test)
mktmpenv
pip search froala
pip install django-froala-editor
The version 2.0.1
gets installed, even though the 2.3.2
is present on the pypi website and the pip search shows a 2.1.0
version.
OS X Yosemity 10.10.5
pip version 8.1.2
python 2.7
Following this conversation I've been able to install the latest version of the editor, but the issue remains.
Hi,
I'm trying to install Froala for a front end form on my site. I'm getting the error: cannot import name JsonResponse and I'm not quite sure what's causing it? I'm probably missing something, but I've went over the docs a couple times and don't seem to be missing anything. Any ideas?
Traceback:
File "/Users/Deron/Sites/project/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
resolver_match = resolver.resolve(request.path_info)
for pattern in self.url_patterns:
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
self._urlconf_module = import_module(self.urlconf_name)
**import**(name)
url(r'^froala_editor/', include('froala_editor.urls')),
urlconf_module = import_module(urlconf_module)
**import**(name)
Exception Type: ImportError at /
Exception Value: cannot import name JsonResponse
I used FroalaField() in models.py and included css and js files to my base html. But looks like this function does not work.
<script> $(function(){ $('#id_description').froalaEditor({"inlineMode": false, "imageUpload": false, "fileUpload": false}) }); </script>
it says on javascript console
Uncaught ReferenceError: $ is not defined
also I have this error
Uncaught TypeError: Cannot read property 'fn' of undefined
at froala_editor.min.js:7
at froala_editor.min.js:7
at froala_editor.min.js:7
Hi,
If I install this package on my Django project, do I need to buy a license to use it?
Trying to use image_tui
, added it like so:
FROALA_EDITOR_THIRD_PARTY = ('image_tui', 'spell_checker', 'font_awesome', 'embedly')
Everything else seems to be working fine, but when I click on the button for advanced image editing, nothing seems to be happening. Using Django 2.1 on Firefox and Chrome.
My deployment process uses AWS and relies and automatic installation of requirements using
pip install
currently it only installs django-froala-editor-2.9.5
and not the newer django-froala-editor-3.0.0b1
The latest version of django-froala-editor 2.3.5 seems not properly uploaded to Pypi.
https://pypi.python.org/pypi/django-froala-editor shows that 2.3.5 is the latest, and there is README (looks like markdown parsing doesn't work but still), however it isn't available for download from pip
client. Instead the pip tries to retrieve 2.0.1 which occurs errors on django 1.9 and above.
In Django admin, using FroalaField/FroalaWidget in inline model breaks the editor. No Froala buttons can be pressed, characters are not counted, placeholder doesn't disappear, no content is saved after submission.
This might be a general problem with formsets.
I'm a fan of behavior testing using Splinter which bases on Selenium. The problem with a FroalaField
in those tests is, that they are not rendered as form fields and so they can not get filled by the default Selenium/Splinter methods. So I would like to be able do deactivate the FroalaEditor when running those tests using settings.py
.
As a proof of concept I implemented this as follows:
from django.conf import settings
from froala_editor.fields import FroalaField
from django.forms.widgets import Textarea
class DeactivatableFroalaField(FroalaField):
"""
FroalaField which allows to disable the FroalaEditor widget
using settings.py's variable USE_FROALA_EDITOR
"""
def formfield(self, **kwargs):
try:
use_froala_editor = settings.USE_FROALA_EDITOR
except AttributeError:
use_froala_editor = True
if use_froala_editor is False:
# disable the Froala Editor by just
# rendering a Textarea
defaults = {
'widget': Textarea()
}
defaults.update(kwargs)
return super(DeactivatableFroalaField, self).formfield(**defaults)
else:
# leave as it is
return super(DeactivatableFroalaField, self).formfield(**kwargs)
As this is quite useful for me, I kindly ask the developers to "incorporate" this idea into the code base.
Fixes in commit 4453402 does not handle custom settings that were added for editor.
Also this fix tries to reinitialize all text areas in added inline, even that does not have froala defined
Hello,
Froala doesn't seem to handle django/jinga template tags too well. For example, it automagically wraps for loops (i.e {% for i in y %}
) in paragraph tags.
This is frustrating but somewhat manageable, however the real issue comes in when dealing with tables. If I have a for loop that sits outside of a tag inside a table, it would take it and append it into single string paragraph at the top.
For example,
<table>
<tr>
{% for user in users %}
<td>{{ user.first_name }}</td>
{% endfor %}
</tr>
</table>
Would become
<p>{% for user in users %} {% endfor %}</p>
<table>
<tr>
<td>{{ user.first_name }}</td>
</tr>
</table>
Even if I'm entering it view the "code" view. This of course makes it unusable for this purpose.
Is there a way to disable formatting, at least when entering things via the "code" view? Or a way to make {{ foo }}
and {% bar %}
exempt from auto-formatting?
Forgive my horrible regex, but I'd like to spare the following three inputs from autoformatting:
({{)(.*)(}})
(i.e {{ foo }}
)({% for)(.*)(endfor %})
(i.e {% for i in x %} foo {% endfor %}
)({% if)(.*)(endif %})
(i.e {% if bar %} foo {% else %} foobar {% endif %}
)if I issue this command a very old version(2.0.1) is invoked for installation.
$ pip install django-froala-editor
Collecting django-froala-editor
Installing collected packages: django-froala-editor
Successfully installed django-froala-editor-2.0.1
$ pip install django-froala-editor==2.4.0
Collecting django-froala-editor==2.4.0
Could not find a version that satisfies the requirement django-froala-editor==2.4.0 (from versions: 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.8.7, 0.9.0, 1.2.1, 1.2.2, 1.2.3, 1.2.3.1, 1.2.3.2, 1.2.4, 1.2.4.1, 1.2.4.2, 1.2.5, 1.2.6, 1.2.7, 2.0.0rc3, 2.0.0rc3.post1, 2.0.1)
No matching distribution found for django-froala-editor==2.4.0
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.