How to serve another static root in Django for html pages?
up vote
0
down vote
favorite
The typical configuration serves two static roots:
http://www.example.org/static/
http://www.example.org/media/
This is STATIC_URL
and MEDIA_URL
.
I would like to add a third one to host static files build with Sphinx:
http://www.example.org/docs/
I know I could configure this on the level of the web server. Is it also possible to configure this on the level of Django?
Here is my python package, that implements Sphinx with Django templates and renders it to static pages. A kind lightweight read-the-docs. Still in an early state, yet working.
https://github.com/elmar-hinz/Django.SphinxCMS
django python-sphinx
add a comment |
up vote
0
down vote
favorite
The typical configuration serves two static roots:
http://www.example.org/static/
http://www.example.org/media/
This is STATIC_URL
and MEDIA_URL
.
I would like to add a third one to host static files build with Sphinx:
http://www.example.org/docs/
I know I could configure this on the level of the web server. Is it also possible to configure this on the level of Django?
Here is my python package, that implements Sphinx with Django templates and renders it to static pages. A kind lightweight read-the-docs. Still in an early state, yet working.
https://github.com/elmar-hinz/Django.SphinxCMS
django python-sphinx
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The typical configuration serves two static roots:
http://www.example.org/static/
http://www.example.org/media/
This is STATIC_URL
and MEDIA_URL
.
I would like to add a third one to host static files build with Sphinx:
http://www.example.org/docs/
I know I could configure this on the level of the web server. Is it also possible to configure this on the level of Django?
Here is my python package, that implements Sphinx with Django templates and renders it to static pages. A kind lightweight read-the-docs. Still in an early state, yet working.
https://github.com/elmar-hinz/Django.SphinxCMS
django python-sphinx
The typical configuration serves two static roots:
http://www.example.org/static/
http://www.example.org/media/
This is STATIC_URL
and MEDIA_URL
.
I would like to add a third one to host static files build with Sphinx:
http://www.example.org/docs/
I know I could configure this on the level of the web server. Is it also possible to configure this on the level of Django?
Here is my python package, that implements Sphinx with Django templates and renders it to static pages. A kind lightweight read-the-docs. Still in an early state, yet working.
https://github.com/elmar-hinz/Django.SphinxCMS
django python-sphinx
django python-sphinx
edited Nov 12 at 6:51
mzjn
31k566152
31k566152
asked Nov 11 at 17:04
Blcknx
770119
770119
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
How about building a url just like you do for the static files? The DOCS_ROOT
setting should be a string in your settings.
from django.urls import re_path
from django.views.static import serve
from django.conf import settings
urlpatterns += [
re_path(r'^docs/(?P<path>.*)', serve, 'document_root': settings.DOCS_ROOT)
]
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
How about building a url just like you do for the static files? The DOCS_ROOT
setting should be a string in your settings.
from django.urls import re_path
from django.views.static import serve
from django.conf import settings
urlpatterns += [
re_path(r'^docs/(?P<path>.*)', serve, 'document_root': settings.DOCS_ROOT)
]
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
add a comment |
up vote
0
down vote
accepted
How about building a url just like you do for the static files? The DOCS_ROOT
setting should be a string in your settings.
from django.urls import re_path
from django.views.static import serve
from django.conf import settings
urlpatterns += [
re_path(r'^docs/(?P<path>.*)', serve, 'document_root': settings.DOCS_ROOT)
]
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
How about building a url just like you do for the static files? The DOCS_ROOT
setting should be a string in your settings.
from django.urls import re_path
from django.views.static import serve
from django.conf import settings
urlpatterns += [
re_path(r'^docs/(?P<path>.*)', serve, 'document_root': settings.DOCS_ROOT)
]
How about building a url just like you do for the static files? The DOCS_ROOT
setting should be a string in your settings.
from django.urls import re_path
from django.views.static import serve
from django.conf import settings
urlpatterns += [
re_path(r'^docs/(?P<path>.*)', serve, 'document_root': settings.DOCS_ROOT)
]
answered Nov 11 at 18:23
nik_m
7,74022139
7,74022139
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
add a comment |
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Thanks, great! It's working out of the box. I edited your answer to also serve in development mode.
– Blcknx
Nov 11 at 18:48
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Glad I was able to help you!
– nik_m
Nov 11 at 19:30
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
Sorry, my edit was rejected by two of three, with the remark I should put that into a comment. I can't put code into a comment.
– Blcknx
Nov 13 at 11:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251094%2fhow-to-serve-another-static-root-in-django-for-html-pages%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown