On 2/08/2012 11:19am, jondbaker wrote:
I'm trying to install django-tinymce so that I can use utilize it within
the admin when editing flatpages and flatblocks. I've been following the
instructions at
http://django-tinymce.readthedocs.org/en/latest/installation.html, but I
can't seem to get TinyMCE to display. django-tinymce has been installed
via pip, and here are the relevant snippets of code:

*settings.py*
INSTALLED_APPS = (
     ...
     'tinymce',
)

I have tinyMCE working and no mention of it in settings.py. It isn't a Django app.

It needs to be served by your web server eg Apache. The important thing is to hang it somewhere off your STATIC_ROOT so your templates can use {{STATIC_URL}}/js/tinymce/ and if Apache has been set up with ...

  Alias /static/ /var/www/<project>/static/
or
  Alias /tiny_mce/ /var/www/<project>/static/js/tiny_mce/

... it should find it. If not, view the page source to see where Apache is actually looking.

It is different when you are using the Django development server. In my urls.py I detect when that is the case with ...

tinymcedir = os.path.join(settings.STATIC_ROOT, 'js/tiny_mce/')

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^media\/(?P<path>.*)$',
                'django.views.static.serve',
                {'document_root': settings.MEDIA_ROOT}),
        )
    urlpatterns += patterns('',
        (r'^static\/(?P<path>.*)$',
                'django.views.static.serve',
                {'document_root': settings.STATIC_ROOT}),
        )

    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += patterns('',
        (r'^tiny_mce/(?P<path>.*)$',
                'django.views.static.serve',
                {'document_root': tinymcedir}),
        )

I'm not sure if this is the "right way" to do it but it works for me.

Mike


PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
TINYMCE_JS_URL = os.path.join(PROJECT_ROOT,
'templates/static/js/tiny_mce/tiny_mce.js')
TINYMCE_JS_ROOT = os.path.join(PROJECT_ROOT, 'templates/static/js/tiny_mce')
* I have a hunch that here is where I'm going wrong. The instructions
indicate that the tiny_mce js dir should reside in MEDIA, but I was
under the impression that MEDIA is to be used for user-uploaded content,
while STATIC is for assets like JS and CSS. That's why I put the
tiny_mce lib in STATIC instead of MEDIA.
*
urls.py*
urlpatterns = patterns(''
     ...
     url(r'^tinymce/', include('tinymce.urls')),
)
* If i visit 'http://127.0.0.1:8000/tinymce/flatpages_link_list/' in the
browser, 'var tinyMCELinkList = []' is rendered.

Any help would be greatly appreciated. Thanks.

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/LzurKyPvBdAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to