1
staticfiles_urlpatterns()
is not designed for production and only works if DEBUG = True
. You need to serve up the static files separately. I’ve never used django with fcgi, but I’m assuming you can pull this off relatively easily.
The files are being looked for at yourdomain.com/static
because that is what you set for your STATIC_URL
First, change your STATIC_ROOT
to a public directory. You should have something like /home2/mlinsenb/public_html
where you put your index.fcgi
file. Create a static
directory here and change your STATIC_ROOT = "/home2/mlinsenb/public_html/static"
You may want to do the same for MEDIA_ROOT
too incase you use it in the future.
Your .htaccess should look like this if you were following the guide you posted:
AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteRule (media/.*)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(admin/.*)$ index.fcgi/$1 [L]
Again, I’m no expert with mod_rewrite, but it looks like they handle the media files with that, so I would try adding one line for your static files:
AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteRule (media/.*)$ - [L]
RewriteRule (static/.*)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(admin/.*)$ index.fcgi/$1 [L]
Then run python manage.py collectstatic
and django should put all of your static files in /home2/mlinsenb/public_html/static
Now hostgator should serve up files at yourdomain.com/static from that directory.
0
Heroku, among others, recommend just letting Django serve your static files using a WSGI plugin. They used to recommend dj-static
, now they recommend whitenoise.
- [Answer]-Django flatpages PAGE NOT FOUND No FlatPage matches the given query
- [Answer]-Is using Django MondgoDB Engine considered mainstream
- [Answer]-Access attributes from retrieved model object in django
- [Answer]-Tastypie Accessing Query Before Data Gets Replaced by Request
- [Answer]-Django Truncate, return false if no truncation occurs?