On May 5 2006, 6:35 pm, "Jakub Labath" <[EMAIL PROTECTED]> wrote: > Hi, > > I have web server that is accessed both via http and https is there a > way for me to tell which is used? > > Thanks
I notice at http://www.djangoproject.com/documentation/request_response/ there's a bit that reads a follows: is_secure() Returns True if the request is secure; that is, if it was made with HTTPS. You have to jump through some context processor hoops to get it as a default context inside the templates. I created a simple general context processor: def general(request): return {'is_secure':request.is_secure()} and added it to my settings.py file TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "hurryup.utils.context_processors.general", ) so now my google-analytics section in my base_template.html looks like the following. Notice the difference in the source for the js: {% if is_secure %} <script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"> {% else %} <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> {% endif %} </script> <script type="text/javascript"> _uacct = "UA-XXXXX"; urchinTracker(); </script> The next bit i need to puzzle out is the switching between https and http in between login and entering credit card details etc. Maybe i should just take the speed hit and run everything as https --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---