M
M
Mistadrumma2016-03-31 22:57:53
Django
Mistadrumma, 2016-03-31 22:57:53

Error in DjangoAdmin with TinyMCE widget. Does anyone know how to fix?

Hello! Does anyone know how to fix? Error in DjangoAdmin with TinyMCE widget.
Swears at the profile argument.

Django Version: 1.9.4
Python Version: 2.7.7
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'castshop',
 'tinymce']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  541.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  244.             return view(request, *args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
  1437.         return self.changeform_view(request, None, form_url, extra_context)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/utils/decorators.py" in inner
  184.                     return func(*args, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
  1367.         ModelForm = self.get_form(request, obj)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in get_form
  639.             return modelform_factory(self.model, **defaults)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/forms/models.py" in modelform_factory
  545.     return type(form)(class_name, (form,), form_class_attrs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/forms/models.py" in __new__
  247.                                       opts.field_classes)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/forms/models.py" in fields_for_model
  176.             formfield = formfield_callback(f, **kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in formfield_for_dbfield
  173.                 return db_field.formfield(**kwargs)

File "/home/c/chzat/.djangovenv/lib/python2.7/site-packages/tinymce/models.py" in formfield
  31.                 profile=self.tinymce_profile)

Exception Type: TypeError at /admin/castshop/articles/add/
Exception Value: __init__() got an unexpected keyword argument 'profile'

As I understand it, the profile is the tinymce config itself.
/home/c/chzat/.djangovenv/lib/python2.7/site-packages/tinymce/models.py in formfield
            'widget': tinymce_widgets.TinyMCE(profile=self.tinymce_profile)
        }
        defaults.update(kwargs)
        # As an ugly hack, we override the admin widget
        if defaults['widget'] == admin_widgets.AdminTextareaWidget:
            defaults['widget'] = tinymce_widgets.AdminTinyMCE(
          profile=self.tinymce_profile) 
        return super(HTMLField, self).formfield(**defaults)

When using admin widget via model, here is the model
class Articles (models.Model):
    class Meta:
        db_table = 'articles'
        ordering = ['-article_date']
    STATUS_CHOICES = (
    ('d', 'Черновик'),
    ('p', 'Опублиованно'),
    ('w', 'Снято'),

)
    article_title = models.CharField(max_length=200, verbose_name='Заголовок')
    article_slug = models.SlugField(default='')
    article_text = HTMLField(verbose_name='Содержание')
    article_user = models.ForeignKey(User, verbose_name='Автор')
    article_date = models.DateTimeField(verbose_name='Дата поста')
    article_like = models.IntegerField(default=0)
    article_status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='d', verbose_name='Статус')
    article_published = models.CharField(max_length=50, default= u'Не один пользователь не опублиовал статью', verbose_name='Опубликовал')
    article_status_ok = models.BooleanField(default=False, verbose_name='В сети')
    article_category = models.ManyToManyField(Category, default='', verbose_name='Категория')
    article_tag = models.ManyToManyField(Tag, default='', verbose_name='Теги')
    def _unicode_(self):
        return self.name

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2016-04-01
@Mistadrumma

This is a known bug . Do you need django-tinymce4? django-tinymce won't work?

Z
zelsky, 2016-03-31
@zelsky

use django-ckeditor

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question