Alejandro Ll.
Alejandro Ll.

Reputation: 185

Django: Issues locating a fourth-party app in INSTALLED_APPS

I'm having this error in the manage.py file when I run the server using the library "ckeditor" (also I got the same error with tinymce):

Traceback (most recent call last):                                                                                                  
  File "manage.py", line 10, in <module>                                                                                            
    execute_from_command_line(sys.argv)                                                                                             
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line          
    utility.execute()                                                                                                               
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 312, in execute                            
    django.setup()                                                                                                                  
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup                                               
    apps.populate(settings.INSTALLED_APPS)                                                                                          
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate                                       
    app_config = AppConfig.create(entry)                                                                                            
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create                                           
    module = import_module(entry)                                                                                                   
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module                                                        
    __import__(name)                                                                                                                
ImportError: No module named ckeditor_uploader

In the shell mode there is no problem importing this library. Also I checked the paths in the shell and sys has access to "site-packages" of venv where it's installed:

$ python manage.py shell
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from ckeditor.fields import RichTextField
>>>
>>> import sys
>>> for x in sys.path: print x 
... 
...
/home/ubuntu/workspace/venv/local/lib/python2.7/site-packages
/home/ubuntu/workspace/venv/lib/python2.7/site-packages

I checked the list of libraries installed with pip list and "django-ckeditor" is there.

Some of my files:

manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

setting.py:

INSTALLED_APPS = (
    'django.contrib.admin',
    ...
    'myapp',
    'ckeditor_uploader',
)
...
CKEDITOR_CONFIGS = {
    'awesome_ckeditor': {
        'toolbar': 'Basic',
    },
}

Pip freeze

$ pip freeze
dj-database-url==0.3.0
dj-static==0.0.6
Django==1.8.5
django-ckeditor==5.0.2
django-toolbelt==0.0.1
gunicorn==19.3.0
psycopg2==2.6.1
static3==0.5.1
virtualenv==13.1.2
wheel==0.26.0

urls.py

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('myapp.urls')),
    url(r'^ckeditor/', include('ckeditor_uploader.urls') ),
]

I read some post with similar problem causes by an older version of pip, but I upgrade it.

Upvotes: 2

Views: 221

Answers (2)

Tomasz Jakub Rup
Tomasz Jakub Rup

Reputation: 10680

Following to https://pypi.python.org/pypi/django-ckeditor/5.0.2

Add ``ckeditor`` to your ``INSTALLED_APPS`` setting.

is required.

Add ``ckeditor_uploader`` to your ``INSTALLED_APPS`` setting.

is required for using widget with file upload.

Add ckeditor and ckeditor_uploader to INSTALLED_APPS.

And:

Add a CKEDITOR_UPLOAD_PATH setting to the project's settings.py file.

Upvotes: 0

Ryan
Ryan

Reputation: 2183

Change your installed apps in settings to:

settings.py:

INSTALLED_APPS = (
    'django.contrib.admin',
    ...
    'myapp',
    'ckeditor',
)
...
CKEDITOR_CONFIGS = {
    'awesome_ckeditor': {
        'toolbar': 'Basic',
    },
}

Also remember to add ckeditor to your urls.py

urlpatterns = patterns(
    '',
    ...
    (r'^ckeditor/', include('ckeditor_uploader.urls')),
    ...
)

Upvotes: 1

Related Questions