How to serve static files in Django development -
here directory structure pf project.
mysite \media \static \images \css base.css \js \templates base.html \settings.py #and other .py files
now if have file c:\mysite\static\css\base.css
or image c:\mysite\static\images\ball.png
.how going serve using django development server. know not recomment way, in development want work. have read docs , other answers on stackoverflow don't seem work. may being confused media
, static
, urlpatterns
. have spent hours trying figure out still no luck. new django , seems me overkill css or image showing up. changes or editing need make work. how referece image , css in template?
here how static files django documentation takes through whole process step-by-step.
add following urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # ... rest of urlconf goes here ... urlpatterns += staticfiles_urlpatterns()
then 'this view automatically enabled , serve static files @ static_url when use built-in runserver management command. ... inspect static_url setting , wire view serve static files accordingly. don't forget set staticfiles_dirs setting appropriately let django.contrib.staticfiles know files additionally files in app directories.'
it worth mentioning inappropriate deployment, work development.
Comments
Post a Comment