When I add STATIC_URL in the urls.py
:
urlpatterns = [...]+static(settings.STATIC_URL)
but there I get the ^static\/(?P<path>.*)$
in the urls.
Shouldn't it be ^static/(?P<path>.*)$
? like the ^media/(?P<path>.*)$
.
in settings.py
:
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR + '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
How to solve this issue? or is there another way to replace the
+static(settings.STATIC_URL)
if has, provide to me for testing, thanks.
There is a way to avoid that issue.
in the urls.py
:
from django.conf.urls.static import serve
if settings.DEBUG:
urlpatterns += [
url(r'^static/(?P<path>.*)$', serve, {
'document_root': settings.STATIC_ROOT
})
]
The result will like this:
^media/(?P<path>.*)$
^static/(?P<path>.*)$ # this is as the same with the media
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With