Opened 4 years ago

Closed 4 years ago

#17645 closed Bug (invalid)

runserver: not serving static for localhost

Reported by: shadow Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Normal Keywords:
Cc: shadow Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

runserver will only serve static files if STATIC_URL is relative. This makes sense if STATIC_URL includes a domain pointing to another server. However, it denies the possibility of including a localhost domain (as is needed by my current project).

I've currently worked around this by modifying: django/contrib/staticfiles/handlers.py

def _should_handle(self, path):
    return True

Sorry, I haven't had time to consider any side effects of this, but it's working for me at the moment.

Change History (2)

comment:1 Changed 4 years ago by shadow

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Sorry, that fix should be:

    def _should_handle(self, path):
        return path.startswith(self.base_url[2])

comment:2 Changed 4 years ago by shadow

  • Resolution set to invalid
  • Status changed from new to closed

Actually, now that I think about it... there won't be an easy way of knowing whether the domain is pointing to 127.0.0.1 or not. So this probably can't be fixed reliably.

Never mind :]

Note: See TracTickets for help on using tickets.
Back to Top