Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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@… 3 years ago.
patch for ticket 16382: adding (commented) staticfiles lines to urls.py

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by wim@…

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

comment:1 Changed 3 years ago by wim@…

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

comment:2 Changed 3 years ago by aaugustin

To the best of my knowledge, it isn't necessary to add anything to the URLconf to serve static files during development. The doc 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?

Last edited 3 years ago by aaugustin (previous) (diff)

comment:3 Changed 3 years ago by jezdez

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

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 3 years ago by jezdez

  • Resolution duplicate deleted
  • Status changed from closed to reopened

comment:5 Changed 3 years ago by jezdez

  • Resolution set to wontfix
  • Status changed from reopened to closed

Err, this is a wontfix :)

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

Totally agree!

I'm sorry, I misread the docs.

Great default by the way, thanks Jannis.

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.