django-admin-bootstrap icon indicating copy to clipboard operation
django-admin-bootstrap copied to clipboard

Works with django server but not with Apache mod_wsgi

Open Brazze66 opened this issue 6 years ago • 1 comments

It complains about django is not defined and (django.jQuery) is highlighted in index.html Its weird as it works fine when using Django dev server. Any idea? static files are missing when collected? Using Django 2.2 and Python 3.6

Brazze66 avatar May 21 '19 01:05 Brazze66

Don't think it's a bug. You probably should let Apache serve static files (as noted in the Django docs somewhere), but this app overrides some of the static files and not others. I followed the Apache docs here and it seems to work for me: https://httpd.apache.org/docs/2.4/en/rewrite/remapping.html#multipledirs Here's what I have in my Apache site config:

 # serve static admin files, as noted in django docs
 <Directory /usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin/>
   AllowOverride None
   Require all granted
 </Directory>
 Alias /static/admin "/usr/local/lib/python3.6/dist-packages/django/contrib/admin/static/admin"
# serve django-admin-bootstrap's own static files for 
 Alias /static/bootstrap_admin /usr/local/lib/python3.6/dist-packages/bootstrap_admin/static/bootstrap_admin
# serve django-admin-bootstrap's version of the admin's static files in priority
 RewriteEngine on
 RewriteCond /usr/local/lib/python3.6/dist-packages/bootstrap_admin/%{REQUEST_URI} -f
 RewriteRule  "^(.+)"  "/usr/local/lib/python3.6/dist-packages/bootstrap_admin/$1"  [L]

The paths should match your own installation of course. If it works for you, it might be worht adding it to the docs.

ls-initiatives avatar Jun 14 '19 15:06 ls-initiatives