Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16832 closed Cleanup/optimization (wontfix)

add staticfiles lines to urls.py ,

Reported by: wim@… Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

During development, static files can be served using:

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()

My proposal is to add these lines, commented, to urls.py so people can enable them quickly.

Attachments (1)

added_staticfiles_to_default_urls.diff (870 bytes) - added by wim@… 5 years ago.
patch for ticket 16382: adding (commented) staticfiles lines to urls.py

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by wim@…

patch for ticket 16382: adding (commented) staticfiles lines to urls.py

comment:1 Changed 5 years ago by wim@…

Easy pickings: set
Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 5 years ago by Aymeric Augustin

To the best of my knowledge, it isn't necessary to add anything to the URLconf to serve static files during development. The docs says:

This view is automatically enabled by runserver (with a DEBUG setting set to True).

(https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.templatetags.staticfiles.django.contrib.staticfiles.views.serve)

What's the use case for adding these lines to the default urls.py?

Version 0, edited 5 years ago by Aymeric Augustin (next)

comment:3 Changed 5 years ago by Jannis Leidel

Resolution: duplicate
Status: newclosed

No no, adding staticfiles_urlpatterns is not necessary when using the development server (via runserver), but only if you use an alternative server, like the 3rd party app gunicorn. I'm not convinced that use case is justifies the addition to the default URL.

comment:4 Changed 5 years ago by Jannis Leidel

Resolution: duplicate
Status: closedreopened

comment:5 Changed 5 years ago by Jannis Leidel

Resolution: wontfix
Status: reopenedclosed

Err, this is a wontfix :)

comment:6 Changed 5 years ago by Wim Feijen <wim@…>

Totally agree!

I'm sorry, I misread the docs.

Great default by the way, thanks Jannis.

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