Changes between Initial Version and Version 1 of Ticket #25598, comment 8


Ignore:
Timestamp:
Jul 21, 2016, 8:53:35 AM (8 years ago)
Author:
Rostyslav Bryzgunov

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25598, comment 8

    initial v1  
    11I'm here at DjangoCon US 2016 will try to create a patch for this ticket ;)
     2
     3== Why? ==
     4
     5But before that, here are some reasons to do it:
     6
     7* `{% url '...' %}` template tag does respect `SCRIPT_NAME` but `{% static '...' %}` does not
     8* `reverse(...)` function does respect `SCRIPT_NAME` but `static(...)` does not
     9
     10So the first reason is '''consistency''' inside Django core.
     11
     12Of course we shouldn't modify `STATIC_URL` when it's an ''absolute URL'', with domain & protocol. But if it starts with `/` - it's ''relative'' to our Django project and we need to add `SCRIPT_NAME` prefix.
     13
     14== Real life example ==
     15
     16You have Django running via WSGI behind reverse proxy (let's call it ''back-end server''), and another HTTP server on the front (let's call it ''front-end server''). Front-end server URL is `http://some.domain.com/sub/path/`, back-end server URL is `http://1.2.3.4:5678/`. You want them both to work. You pass `SCRIPT_NAME = '/sub/path/'` from front-end server to back-end one. But when you access back-end server directly - there is no `SCRIPT_NAME` passed to WSGI/Django.
     17
     18So we cannot ''hard-code'' `SCRIPT_NAME` in Django settings because it's dynamic.
Back to Top