Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14582 closed (fixed)

django.contrib.staticfiles development file serving is backward-incompatible if MEDIA_URL was pointing to /static/ folder

Reported by: kmike Owned by: jezdez
Component: Contrib apps Version: master
Severity: Keywords: staticfiles
Cc: tkaemming Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

My project has these settings:

# settings.py
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'static')
MEDIA_URL = '/static/'
#urls.py
if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )

after updating from django 1.2 to django trunk @14352 static files serving during development becomes broken: all requests to static files return 404 error now.

Attachments (1)

ticket-14582.diff (1.6 KB) - added by tkaemming 3 years ago.
Adds --nostatic option to "runserver" management command.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 3 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by jezdez

  • Owner changed from nobody to jezdez
  • Status changed from new to assigned

Changed 3 years ago by tkaemming

Adds --nostatic option to "runserver" management command.

comment:3 Changed 3 years ago by tkaemming

  • Cc tkaemming added
  • Has patch set

I've created a patch for this that adds a "--nostatic" option to the "runserver" management command which prevents the StaticFilesHandler from being loaded. If the option is not used, the StaticFilesHandler will be used (as it is currently on trunk at r14509).

This seems like a more appropriate solution than using django.conf.settings, since it only affects the "runserver" manage command.

If this patch needs additional tests or documentation, I'd be happy to help with that as well.

comment:4 Changed 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [14533]) Fixed #14524, #14582, #14617, #14665 and #14667 -- Tweaked staticfiles app.

  • Updated StaticFilesHandler and AdminMediaHandler to make use of the 404 handler if needed.
  • Updated runserver management command to serve static files only in DEBUG mode (or if specified the --insecure option) and if the staticfiles app is in INSTALLED_APPS. Also added an option to disable serving completely (--nostatic).
  • Added check in debug mode if STATICFILES_* settings are different to MEDIA_* settings.
  • Removed a faulty PendingDeprecationWarning in AdminMediaHandler that is triggered every time runserver is used.
  • Fixed an issue with the modification time checks when running collectstatic.
  • Extended and refined documentation.

Thanks to everyone for input, especially to Carl Meyer, Ted Kaemming and
Adam Vandenberg for patches.

comment:3 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.