Forums

Cannot load static files in virtual environment

My Django site is still under development, and everything works fine. I recently installed django-session-security ver 2.6.0rc1 which helps to timeout user session after some pre-determined time. After 1 minute, for instance, a dialog box is supposed to come out, warning of time out unless a key is pressed or mouse moved. If inactivity persist, it timeout. This works on my computer with no problems -- and on some level on PA too. On PA, inactivity successfully timeout, but no messages are shown.

Checking the server and error logs showed:

Not Found: /static/session_security/script.js
Not Found: /static/session_security/style.css

The files in question are located under my virtual environment at:

/home/user_name/.virtualenvs/user_webapp_venv/lib/python3.6/site-packages/session_security/static/session_security

In one of the django-session-security file, all.html (which is located under home/user_name/.virtualenvs/user_webapp_venv/lib/python3.6/site-packages/session_security/templates/session_security/all.htm) I find this statement:

{% load session_security_tags %}
{% load i18n l10n %}
{% load static from staticfiles %}

In my settings.py, I have this:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

which works fine in my own webapp -- but not good enough for django-session-security. What can I do so that this module can find its own static files?

Thanks for any help.

Ah, I needed to run manage.py collectstatic then set the /static/ URL path in PA static to point to the right path set by collectstatic.

Great! Let us know if you have any other problems!

             / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\
<<<<<<:>~  <   Yay!          |
             \_________/