How to write css path on django setting file when django running on apache with mod_wsgi.
I write apache setting file as below.
#httpd.conf
WSGIPythonHome /opt/python3.4
WSGIPythonPath /opt/python3.4/bin/python3
WSGIScriptAlias / /usr/local/django/mysite/mysite/wsgi.py
Alias /static/ /usr/local/django/mysite/mysite/static/
This Alias command is for CSS path on admin site of django.
I copy static files for admin site.
How to use Django with Apache and mod_wsgi
I am using django version 1.7 and leading tutorial for 1.7.
Tutorial 6 is how to use static CSS and image file on django.
My django file tree is as below
mysite
- manage.py
+ mysite
- settings.py
+ static
- urls.py
- wsgi.py
+ polls
- admin.py
- models.py
+ templates
+ polls
- index.html
- urls.py
+ static
+ polls
- style.css
- views.py
mysite/settings.py
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT,'static')
style.css is used by polls/templates/polls/views.py
polls/templates/polls/views.py
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />
I accessed localhost.
However, CSS file for polls does not find. (localhost/static/polls/style.css)
If I modify httpd.conf file as below.
WSGIPythonHome /opt/python3.4
WSGIPythonPath /opt/python3.4/bin/python3
WSGIScriptAlias / /usr/local/django/mysite/mysite/wsgi.py
Alias /static/ /usr/local/django/mysite/polls/static/polls/
It can use static file on polls application.
However, in this case, I can not find static file for admin site.
I would like to use static file on administrate site and my applications.
How can I use Static file on apache with mod_wsgi?
STATIC_ROOTto a dir outside your project, adjust httpd.conf accordingly, then runmanage.py collectstaticdocs.djangoproject.com/en/1.7/ref/contrib/staticfiles/…