3

I can't seem to find any way to hange editor size in TinyMCE. I edit posts on my site in Django administration and to make it easier I looked for a better editor than just a textfield. I succesfully installed TinyMCE, but the editor is tiny, which makes editing very annoying.

Here's how it looks like.

Here is my models.py

from django.db import models
from tinymce.models import HTMLField

class Post(models.Model):
    title = models.CharField(max_length=140)
    # body = models.TextField()
    date = models.DateTimeField()
    body = HTMLField()

    def __str__(self):
        return self.title

Here is my admin.py:

from django.contrib import admin
from blog.models import Post

admin.site.register(Post)

And here is my urls.py:

from django.conf.urls import url, include
from django.views.generic import ListView, DetailView
from .models import Post

urlpatterns = [
    url(r'^$', ListView.as_view(
        queryset=Post.objects.all().order_by("-date")[:25],
        template_name='blog/blog.html')),
    url(r'^(?P<pk>\d+)$',
        DetailView.as_view(model=Post,
                           template_name='blog/post.html')),
]

I've been trying and googling for the past 2 hours, but I can't figure it out.

Can anyone help me? Thanks.

  • if you use this plugin: https://github.com/aljosa/django-tinymce, then in the docs (http://django-tinymce.readthedocs.io/en/latest/installation.html#configuration) you can see a TINYMCE_DEFAULT_CONFIG setting which can be used to config the editor, and here you can find some options: https://www.tinymce.com/docs/configure/editor-appearance/, so try adding something like `TINYMCE_DEFAULT_CONFIG = {'theme': "simple", 'relative_urls': False, 'width': '100%', 'height': 300}` in your settings.py – abidibo Sep 06 '16 at 15:33
  • It worked, thank you :) – Tomáš Horecký Sep 06 '16 at 17:05
  • I'll add it as an answer to help people searching for the same answer. Feel free to accept it, it is more evident for people having the same problem as yours. – abidibo Sep 07 '16 at 07:46

2 Answers2

10

As said in the docs (http://django-tinymce.readthedocs.io/en/latest/installation.html#configuration), there is the TINYMCE_DEFAULT_CONFIG setting which can be used to configure the editor. Just look for available options here: https://www.tinymce.com/docs/configure/editor-appearance/.

In your case, I think something like this may work:

TINYMCE_DEFAULT_CONFIG = {
    'theme': "simple", # default value
    'relative_urls': False, # default value
    'width': '100%',
    'height': 300
}

Put it in your settings.py

abidibo
  • 4,175
  • 2
  • 25
  • 33
  • I figured I was using an older version, so I downloaded a newer one and now the editor [looks great](https://horeckyt.com/static/images/editor_new.png) – Tomáš Horecký Sep 08 '16 at 21:15
2

TINYMCE_DEFAULT_CONFIG dictionary needs to set in the settings.py file.

TINYMCE_DEFAULT_CONFIG = {
    'theme': "advanced",
    'width' : 758,
    'height' : 118,
}

This will change width and height of the tinymce editor.

Basant Kumar
  • 129
  • 1
  • 3