I recently deployed a Django project to my DigitalOcean Droplet. I need to access it in a subfolder of root (i.e. www.domainname.com/). So far this works using the WSGI Aliasing in the apache config files. I am having trouble serving static js files though.
I am using the {% static %} tag in templates to do this. However my js files seem to always be replaced by the current page's html when I inspect them in the browser. Here are my static related settings in settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/html/<project name>/static'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "/static"),
]
UPDATE 1
Here's my apache configuiration:
In sites-available/default:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<VirtualHost <project name>:8000>
ServerName <project name>
ServerAlias <domain>/<project name>
ServerAdmin <email>
DocumentRoot /var/www/html/<project name>
WSGIScriptAlias /<project name>/ /var/www/html/<project name>/<project name>/wsgi.py
ErrorLog /var/www/html/logs/error.log
CustomLog /var/www/html/logs/custom.log combined
WSGIPythonPath /var/www/html/<project name>
</VirtualHost>
In apache2.conf:
WSGIScriptAlias /<project name> /var/www/html/<project name>/<project name>/wsgi.py
WSGIPythonPath /var/www/html/<project name>
<Directory /var/www/html/<project name>>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
UPDATE 2
It appears the .js files are being requested by appending the static path to the path of the current page, i.e.
<domain name>.com/<project name>/<app name>/<page>/<project name>/static/js/<js file name>