TinyMCE editors disappearing in Django admin interface for new model instances

318 views Asked by At

In the Django admin interface, have sections which, when I add a new section, don't display the WYSIWYG HTML editor in the form.

# models.py
class CustomSectionBase(models.Model):
    name = models.CharField(max_length = QUARTER_SIZE, verbose_name = 'Name', null = True, blank = True, default = None)
    body = HTMLField(verbose_name = "Body Text")

    class Meta:
        abstract = True
        verbose_name_plural = "Custom Sections"
        verbose_name = "Custom Section"
        ordering = ['name']

    def __unicode__(self):
        return self.name

    def __repr__(self):
        return unicode(self)

class CompanyCustomSection(CustomSectionBase):
    company = models.ForeignKey(Company, verbose_name = 'Company')

And in the admin interface:

# admin.py
class CompanyCustomSectionInline(NestedStackedInline):
    model = models.CompanyCustomSection
    list_display = ('name', 'body')
    extra = 0

When I run this, the CompanyCustomSections appear with the TinyMCE WYSIWYG HTML editor attached to the body field as expected. However, when I click "Add another Custom Section" in the admin interface, the blank form which appears has a plaintext textarea for the body field instead of the WYSIWYG editor.

I've looked around and found a few people with problems of disappearing TinyMCE editors and tried out some of their solutions. I tried adding the TinyMCE Javascript files to the js property on the CompanyCustomSectionInline and I tried using a custom ModelForm to be sure that the same form is being served for creating and editing the models, but to no avail.

Even if you don't have solutions, any ideas for something for me to look into would be appreciated.

0

There are 0 answers