You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

urls.py 498B

12345678910111213141516171819
  1. from django.conf import settings
  2. from django.conf.urls.static import static
  3. from django.contrib.staticfiles.views import serve
  4. urlpatterns = []
  5. def staticfiles_urlpatterns(prefix=None):
  6. """
  7. Helper function to return a URL pattern for serving static files.
  8. """
  9. if prefix is None:
  10. prefix = settings.STATIC_URL
  11. return static(prefix, view=serve)
  12. # Only append if urlpatterns are empty
  13. if settings.DEBUG and not urlpatterns:
  14. urlpatterns += staticfiles_urlpatterns()