Django static files not loading (production) -
i can not see static files when running project on server (at desktop ok).
when image path on browser have
/static/app_name/images/image_name my images stored @
www.mydomain.com/xxx/xxx/static/app_name/images/image_name i tried adjust settings.py from
'/static/' to
'/xxx/xxx/static/' but seems have no effect images path on browser still
/static/app_name/images/image_name , not /xxx/xxx/static/app_name/images/image_name am missing here?
thanks help!
changing static_url = '/static/' going alter url, not images served.
make sure static_root pointing /path/to/www.mydomain.com/xxx/xxx/static/ , create sure are using hard-coded paths in settings.py, not
os.path.join(os.path.dirname(__file__, 'static')) then in templates
<!-- either --> <img src="{{ static_url }}img/my_image.png" /> <!-- or --> {% load static %} <img src="{% static 'img/my_image.png' %}" /> also, sure you're running python manage.py collectstatic collect of static files of apps place them in static_root directory.
depending on server you're using, create sure have path alias points static directory. example, in apache in /sites-available/www.mydomain.com conf create sure alias directive exists
<virtualhost *:80> ... alias /static /path/to/www.mydomain.com/xxx/xxx/static/ ... </virtualhost> django
No comments:
Post a Comment