Forums

unable to install WYSIWYG editor

hi I am trying to install Froala editor. On local PC is running fine, do you know thy I get this error when installing on a server:

17:58 ~ $ pip3.5 install django-froala-editor                                                                                                                                                          Collecting django-froala-editor  Using cached django-froala-editor-2.0.1.tar.gzBuilding wheels for collected packages: django-froala-editor  Running setup.py bdist_wheel for django-froala-editor ... done  Stored in directory: /home/dzikuss98/.cache/pip/wheels/40/a8/3b/a046deb9fec9ae9a8c169eba48e66c1c0baf7b698ce11a5e94Successfully built django-froala-editorInstalling collected packages: django-froala-editorException:Traceback (most recent call last):  File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main    status = self.run(options, args)  File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 317, in run    prefix=options.prefix_path,  File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 742, in install    **kwargs  File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 831, in install    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)  File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 1032, in move_wheel_files    isolated=self.isolated,  File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 346, in move_wheel_files    clobber(source, lib_dir, True)  File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 317, in clobber    ensure_dir(destdir)  File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 83, in ensure_dir    os.makedirs(path)  File "/usr/lib/python3.5/os.py", line 241, in makedirs    mkdir(name, mode)PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/froala_editor'17:59 ~ $

If you're on PythonAnywhere, there's an extra flag you need to provide when installing modules. More information on this help page.

thanks that helped

but........., I have another one, please check below:

File "/home/dzikuss98/.local/lib/python3.5/site-packages/froala_editor/urls.py", line 1, in <module>
    from django.conf.urls import patterns, url
ImportError: cannot import name 'patterns'
2017-01-10 20:49:19,927 :Error running WSGI application
2017-01-10 20:49:19,929 :ImportError: cannot import name 'patterns'
2017-01-10 20:49:19,929 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/whitenoise/base.py", line 66, in __call__
2017-01-10 20:49:19,929 :    return self.application(environ, start_response)
2017-01-10 20:49:19,929 :
2017-01-10 20:49:19,929 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2017-01-10 20:49:19,930 :    response = self.get_response(request)
2017-01-10 20:49:19,930 :
2017-01-10 20:49:19,930 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
2017-01-10 20:49:19,930 :    response = self._middleware_chain(request)
2017-01-10 20:49:19,930 :
2017-01-10 20:49:19,930 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
2017-01-10 20:49:19,930 :    response = response_for_exception(request, exc)
2017-01-10 20:49:19,930 :
2017-01-10 20:49:19,930 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 86, in response_for_exception
2017-01-10 20:49:19,930 :    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2017-01-10 20:49:19,930 :
2017-01-10 20:49:19,931 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 131, in handle_uncaught_exception
2017-01-10 20:49:19,931 :    if resolver.urlconf_module is None:
2017-01-10 20:49:19,931 :
2017-01-10 20:49:19,931 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
2017-01-10 20:49:19,931 :    res = instance.__dict__[self.name] = self.func(instance)
2017-01-10 20:49:19,931 :
2017-01-10 20:49:19,931 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
2017-01-10 20:49:19,931 :    return import_module(self.urlconf_name)
2017-01-10 20:49:19,931 :
2017-01-10 20:49:19,931 :  File "/home/dzikuss98/My-stuff/mysite/mysite/urls.py", line 26, in <module>
2017-01-10 20:49:19,931 :    url(r'^froala_editor/', include('froala_editor.urls'))#,url('^markdown/', include( 'django_markdown.urls')#) #wyswigp#
2017-01-10 20:49:19,932 :
2017-01-10 20:49:19,932 :  File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/conf/urls/__init__.py", line 50, in include
2017-01-10 20:49:19,932 :    urlconf_module = import_module(urlconf_module)
2017-01-10 20:49:19,932 :
2017-01-10 20:49:19,932 :  File "/home/dzikuss98/.local/lib/python3.5/site-packages/froala_editor/urls.py", line 1, in <module>
2017-01-10 20:49:19,932 :    from django.conf.urls import patterns, url

I am pretty sure that is because on my PC I have older Django version On sever in newer, how to resolve that issue

yup- that's because it's been deprecated and not available on django 1.10

you can either change your code for the more updated django version or use a virtualenv to use a lower django version.

Here's a link to the documentation on how to use a virtualenv for a website on PythonAnywhere. If you use one you can choose any version of Django you want.

I am not sure if I want to change django version. It would be better to update code

But How can update code as below error indicates that fault is in froala editor Can I edit it's files or how this can be solved:

File "/home/dzikuss98/.local/lib/python3.5/site-packages/froala_editor/urls.py", line 1, in <module>
2017-01-10 20:49:19,932 :    from django.conf.urls import patterns, url

It looks like the version that package on PyPI (which is the one you'd install with pip3.5) is quite old -- see this github issue. I suggest you install the latest version directly from github using the command

pip3.5 install --user git+https://github.com/froala/django-froala-editor

...in a bash console, and see if that helps.

hi there, thanks for assistance that helped!

but I have another issue, froala WYSIWYG is not showing in admin. No idea why, I had edited some models and run migration but there was nothing to migrate

I have same code as in local version but WYSIWYG is not showing :(

Are you correctly serving the files necessary for the editor to work? Check your browser network debugger to see whether the files are being retrieved by the browser.

thanks for update..........

But I am on basic level and not sure how to check what you advised

Look in the network section of your browser developer tools while you load the page where you expect the editor to be. See if there are requests for the editor javascript and whether they are successful.

I have got like hundreds of this kind of errors:

base.css 200 stylesheet (index):6 (from disk cache) 77 ms
forms.css 200 stylesheet (index):7 2.4 KB 368 ms
jsi18n/ 200 script (index):10 1.2 KB 315 ms
font-awesome.min.css 200 stylesheet (index):11 6.2 KB 535 ms
froala_editor.min.css 404 stylesheet (index):12 244 B 338 ms
froala_style.min.css 404 stylesheet (index):13 244 B 341 ms
froala-django.css 404 stylesheet (index):14 244 B 342 ms
char_counter.min.css 404 stylesheet (index):15 244 B 726 ms
code_view.min.css 404 stylesheet (index):16 244 B 717 ms
colors.min.css 404 stylesheet (index):17 244 B 714 ms
draggable.min.css 404 stylesheet (index):18 244 B 717 ms
emoticons.min.css 404 stylesheet (index):19 244 B 714 ms
file.min.css 404 stylesheet (index):20 244 B 720 ms
fullscreen.min.css 404 stylesheet (index):21 244 B 719 ms
image.min.css 404 stylesheet (index):22 244 B 723 ms
image_manager.min.css 404 stylesheet (index):23 244 B 724 ms
line_breaker.min.css 404 stylesheet (index):24 244 B 728 ms
quick_insert.min.css 404 stylesheet (index):25 244 B 817 ms
table.min.css 404 stylesheet (index):26 244 B 862 ms
video.min.css 404 stylesheet (index):27 244 B 856 ms

any advice what to do in this situation

I took a look at your webapp config, and I think there's a problem there. You're mapping STATIC_ROOT to the directory containing your static files. You should use the actual value of STATIC_ROOT, as it is set in settings.py -- not the string "STATIC_ROOT"

Oh, and you'll need to reload the website (using the button at the top of the "Web" tab) after you've done that.

I am sorry but I do not understand, which file you mean as webapp cofig?

settings.py probably, vs what you have in the PythonAnywhere webapps tab (there is a section about static file mappings)

ok, thanks for assistans

so in webapp config I have entered this values:

URL                     Directory
STATIC_ROOT /home/dzikuss98/My-stuff/mysite/personal/Static

and this is from settings.py

STATIC_ROOT = '/home/dzikuss98/My-stuff/mysite/personal/Static/'

I am not sure what is wrong here. I just copied initially path from settings to webapp config

STATIC_ROOT is not a URL, it's a variable name. Have a look at the docs for setting up statis files: here and here

I it is a bit better now :)

all ccs is working fine now except froala editor css, see below:

Request URL:http://dzikuss98.pythonanywhere.com/Static/froala_editor/css/froala_editor.min.css
Request Method:GET
Status Code:404 Not Found
Remote Address:50.19.109.98:80

issue is here that css for froala should be in this path : http://dzikuss98.pythonanywhere.com/Static/froala_editor

but froala_editor doesn't exists. I though that it will be created after running collectstatic, but still not there

Do you know how to make this work

is fraola editor supposed to automatically have those static files?

no idea..... how I can check it?

hi All,

does anyone have any suggestions for this?

Looks like you probably need to copy the static files from your git checkout into your Django app.

hi it's me again:

all is running fine, but when SAVE blog post via admin I got 500 error and below :

>  File
> "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/db/backends/utils.py",
> line 64, in execute
>     return self.cursor.execute(sql, params)   File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py",
> line 337, in execute
>     return Database.Cursor.execute(self, query, params) sqlite3.IntegrityError: NOT NULL constraint failed: blog_post.img
> 
> The above exception was the direct cause of the following exception:
> 
> Traceback (most recent call last):   File
> "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/exception.py",
> line 39, in inner
>     response = get_response(request)   File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py",
> line 249, in _legacy_get_response
>     response = self._get_response(request)   File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py",
> line 187, in _get_response
>     response = self.process_exception_by_middleware(e, request)   File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py",
> line 185, in _get_response
>     response = wrapped_callback(request, *callback_args, **callback_kwargs)   File "/home/dzikuss98/My-stuff/myvenv/lib/python3.5/site-packages/django/contrib/admin/options.py",
> line 544, in wrapper

In your models, you've specified that a blog post cannot have a null img attribute, but you're trying to save a blog post without specifying img

yes, thanks for helping!!

my page is now 99% ready :) ......but I have I hope last question: pizctures not shown on my main blog page

If you go here pictures are visible: http://dzikuss98.pythonanywhere.com/13

but if you go here : http://dzikuss98.pythonanywhere.com/

no picture, just this is visible:

017-01-25 rrrrrrrr

<p><br><img class="fr-dib fr-draggable" src="https://i.froala.com/assets/photo1.jpg" data-id="1" data-type="image" data-name="Image 2016-12-22 at 17:12:14.jpg" style="width: 300px;">wia. Znamy następcę<br>Pilna...

2017-01-25 r

<p>rr</p>

2016-12-30 ffsdfsdf

to dzisiejdzym sxx

2016-12-30 ktos jest diablem

attaching template for main blog:

{% extends "personal/header.html" %}
{% block content %}
    {% for post in object_list %}
        <h5>{{ post.date|date:"Y-m-d" }}<a href="{{post.id}}"> <b> {{ post.title }}</b></a></h5>

        {{ post.body|linebreaks|truncatechars:300 }}


    {% endfor %}
{% endblock %}

it's because it's wrapping all of that inside of a <p> tag, so then the <br>, <img> etc aren't being rendered (since they are inside of a <p>).

You're dumping text into the page with your post.body tag and DJango is escaping it because just dumping unescaped text into your page can be a major security problem. The docs are here

THANKS a LOT all of you for assistance All is great now ! :)

This is how template works now

{% extends "personal/header.html" %}
{% block content %}

    {% for post in object_list %}
    {% autoescape off %}
        <h5>{{ post.date|date:"Y-m-d" }}<a href="{{post.id}}"> <b> {{ post.title }}</b></a></h5>

        {{ post.body|linebreaks|truncatechars:300 }}

    {% endautoescape %}
    {% endfor %}
{% endblock %}

Actually two small cosmetic questions:

  • all pictures are adjusted to left but I cannot find anywhere in code any value responsible for that
  • how to add" read more" button but this should be set by me when I edit post, so I cannot use sth like truncatechars as this will defined for all post, I would like to something for each post indywidually

Hi there, at this point we're getting outside the realm of "pythonanywhere support" and into "help programming django", which is outside our remit I'm afraid. You might be able to get some help on the django forums, or via codementor?