Sunday, August 5, 2012

Dynamically adjusting STATIC_URL depending on http or https requests?

I've been tackling the problem of serving both the frontend (http) and the admin (https) site of a Django application from a single instance of the application.
I ran a successful test on webfaction serving the application with nginx+gunicorn and having nginx take care of redirecing /admin urls to https. So far, so 
good, except that the sites STATIC_URL is either http or https and then I run into browsers not playing nice with mixed content.

It seems to me that if I could somehow arrange for the STATIC_URL to dynamically adjust itself to use https:// when Django handles a request that is secured, 
then the problem would go away.  I tried just setting the context value of STATIC_URL in a template context processor function, but templates that use the 'static' template 
tag are not effected by this trick. Is there another way this can be accomplished?



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LdxLkf8B18EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate