Skip to content

Commit

Permalink
Fallback on os.path if the INSTALLED_APPS is not properly loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Jan 21, 2019
1 parent 9839dd5 commit aed10cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tinymce/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from django.conf import settings
from django.contrib.staticfiles import finders
from django.core.exceptions import AppRegistryNotReady

DEFAULT_CONFIG = getattr(settings, 'TINYMCE_DEFAULT_CONFIG',
{'theme': "simple", 'relative_urls': False})
Expand All @@ -16,7 +16,11 @@

if 'staticfiles' in settings.INSTALLED_APPS or 'django.contrib.staticfiles' in settings.INSTALLED_APPS:
JS_URL = getattr(settings, 'TINYMCE_JS_URL', os.path.join(settings.STATIC_URL, 'tiny_mce/tiny_mce.js'))
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', finders.find('tiny_mce', all=False))
try:
from django.contrib.staticfiles import finders
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', finders.find('tiny_mce', all=False))
except AppRegistryNotReady:
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', os.path.join(settings.STATIC_ROOT, 'tiny_mce'))
else:
JS_URL = getattr(settings, 'TINYMCE_JS_URL', '{!s}js/tiny_mce/tiny_mce.js'.format(settings.MEDIA_URL))
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT', os.path.join(settings.MEDIA_ROOT, 'js/tiny_mce'))
Expand Down

0 comments on commit aed10cd

Please sign in to comment.