0
votes

I am trying to get this package to work in Django: https://github.com/romanvm/django-tinymce4-lite

I'm using docker compose for my django installation. The setup is identical to this one here: https://docs.docker.com/compose/django/

Earlier when I encountered similar errors it had to do with the pip package not being properly loaded in docker. Now, I have loaded the "django-tinymce4-lite" package as follows:

  • I have edited my requirements.txt in my project
  • I have rebuilt my docker image
  • When I log onto the docker instance, I can check the presence of the package using this:

    $ pip freeze Django==2.0.6 django-bootstrap3==10.0.1 django-tinymce4-lite==1.7.1 jsmin==2.2.2 Pillow==5.1.0 psycopg2-binary==2.7.4 pytz==2018.4

This seems to be in line with my requirements.txt file:

Django>=2.0
psycopg2-binary
django-bootstrap3
django-tinymce4-lite
Pillow

However, when I follow the instructions I do this:

  1. Add tinymce to INSTALLED_APPS in settings.py for your Django project

    INSTALLED_APPS = ( ... 'tinymce', )

  2. Add tinymce.urls to urls.py for your project:

    urlpatterns = [ ... url(r'^tinymce/', include('tinymce.urls')), ... ]

NOTE: because I use Django 2 I have had to rewrite this. Here is what I use:

path('tinymce/', include('tinymce.urls')),

I have tried this both in my main project urls.py as well as in my app urls.py. The next step is:

In your code:

from django.db import models
from tinymce import HTMLField

class MyModel(models.Model):
    ...
    content = HTMLField('Content')

However, the moment that I do this, I get this error:

AttributeError: module 'django.db.models' has no attribute 'HTMLField'

Anybody any idea how I could further debug/investigate this?

1
Check to make sure you haven't accidentally typed models.HTMLField somewhere; and try deleting any *.pyc files. - Burhan Khalid
That was it, thanks @BurhanKhalid! The problem was a reference to models.HTMLField instead of HTMLField (without the models.!). Could you add this as an answer to confirm it? - user585936

1 Answers

0
votes

The error means you are trying to access the HTMLField attribute of the models class; so probably somewhere you have typed models.HTMLField by mistake.