Forums

Using "ckeditor" with "machina forums?"

This is a more-general question – just hoping to find someone who already knows.

("To save my forehead," y'know.) ;-)

I want to use CKEditor in conjunction with Machina forums, and I specifically want to be able to "drag and drop" images. I've found the right CKEditor feature to do that, but I'm getting "Incorrect Server Response" messages from CKEditor when I try to accomplish the drop. (This also happens on my development box.)

So is there anyone out there who might say – "oh yeah, that happened to me, too, and the way to fix it is ...?"

I don't have any experience with ckeditor/machina forums, but what is the response that you see when you open your brower's dev tools and track the network request? Perhaps that might provide some insight.

Well, what do you know? I figured it out.

The problem was – and, as the django-ckeditor documentation clearly states, the default urlpattern entries (in the include file) specify a "staff-only" decorator for uploads. So, ckeditor was getting an error-message response ... unless, of course, you were a staff-member, and of course it didn't know what to do.

To solve the problem:

First, of course, be sure that ckeditor_uploader (as well as ckeditor) is installed in your virtualenv, and that it is in your INSTALLED_APPS list in settings.py.

Now, in your urls.py, first add this line near the top:

from ckeditor_uploader import views as uploader_views

Next, insert the urlpattern entries that you find in the package's urls.py file, but referencing the uploader_views alias, viz:

url(r'^ckeditor/upload/',
    uploader_views.upload, name='ckeditor_upload'),
url(r'^ckeditor/browse/',
    never_cache(uploader_views.browse), name='ckeditor_browse'),

FYI: If you erroneously attempt to specify ckeditor_uploader.views. in the url() entry, you will be rewarded with:

NameError: name 'ckeditor_uploader' is not defined

Now you know! :-)

Glad you worked it out :-)

"Yeah, sometimes I amaze even myself™ ..." ;-)

One other setting that I forgot to "expressly, for-completeness" mention is:

MACHINA_MARKUP_WIDGET = 'ckeditor_uploader.widgets.CKEditorUploadingWidget'

As the django-ckeditor documentation is, in fact, careful to point out, if you want to "drag and drop," therefore to perform file-uploads, you must either use the appropriate Django ckeditor_uploader field-types or, equivalently, use the corresponding widget from the same package. And then, as the Machina documents also carefully tell you, you must tell Machina to use that widget.

"And, when you actually do what they tell you to do ... ;-) ... lo, it works!"

:D

              / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\
<<<<<<:>~  <   Yay!           |
              \_________/