Josh Jones
Josh Jones

Reputation: 25

I import the module TinyMCE and the django isnt working

I think I have a outdated verison of TinyMCE and i was wondering how to fix the ImportError: cannot import name 'TinyMCE' from 'tinymce'. It was working before i

form.py

from django import forms
from tinymce import TinyMCE
from .models import Post, Comment


class TinyMCEWidget(TinyMCE):
    def use_required_attribute(self, *args):
        return False


class PostForm(forms.ModelForm):
    content = forms.CharField(
        widget=TinyMCEWidget(
            attrs={'required': False, 'cols': 30, 'rows': 10}
        )
    )

    class Meta:
        model = Post
        fields = ('title', 'overview', 'content', 'thumbnail', 
                  'categories', 'featured', 'previous_post', 'next_post')


class CommentForm(forms.ModelForm):
    content = forms.CharField(widget=forms.Textarea(attrs={
        'class': 'form-control',
        'placeholder': 'Type your comment',
        'id': 'usercomment',
        'rows': '4'
     }))

     class Meta:
        model = Comment
        fields = ('content', )

Upvotes: 0

Views: 1436

Answers (1)

Josh Jones
Josh Jones

Reputation: 25

nvm i changed

from tinymce import TinyMCE

to

from tinymce.widgets import TinyMCE

then is worked

Upvotes: 2

Related Questions