As I said in the title I can't import my css file in TINYMCE_DEFAULT_CONFIG variable 'content_css'.
I'm using django-tinymce4-lite package and setting 'content_css'
in my settings.py
file
I've tried with the boostrap cdn like this:
'content_css': 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'
and it worked but if I do something like this:
"content_css": os.path.join(STATIC_URL, "css/style.css")
I have the following 404 error:
"GET /static/css/style.css HTTP/1.1" 404 1764
my css file is in a static folder located in the root directory of my project like this:
/static/css/style.css
and my Static conf is:
settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
urls.py
urlpatterns = [
path("grappelli/", include("grappelli.urls")),
path("admin/", admin.site.urls),
path("admin/filebrowser/", site.urls),
path("tinymce/", include("tinymce.urls")),
path("page/", include("pages.urls")),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
It's been a whole day looking for a solution, even the smallest clue is welcome. Thanks
EDIT:
I'm in DEBUG mode running 'python manage.py runserver'
Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
django = "*"
black = "*"
psycopg2-binary = "*"
pillow = "*"
django-tinymce4-lite = "*"
django-filebrowser-no-grappelli = "*"
[requires]
python_version = "3.6"
Add STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"), )
to your settings.
Also remove STATIC_ROOT
for your development settings or change it to something that's outside the project directory, for example one level higher:
STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', 'static'))
This will make django collect static files to a static directory next to your project directory (but it could be a different location altogether, where your webserver will fetch them directly when you don't run runserver
)
Note I wrote a more thorough explanation of the various settings, especially when deploying to production here on SO and here in a blog post