Mag*_*ivi 5 python django python-2.7 cloud9-ide django-1.6
我正在使用通常的./manage.py运行服务器在Cloud9中运行我的Django应用程序以进行开发.但对于外部世界,可通过https:// URL访问该应用.
问题是,当我使用URL反向函数时,返回的URL以http://开头(至少在某些时候).当我尝试重定向到其中一个URL时,我在控制台中收到类似这样的错误:
Mixed Content: The page at 'https://apps.facebook.com/xxxx/'
was loaded over HTTPS, but requested an insecure form action
'http://xxxx.c9users.io/facebook_app/gift_shop/'.
This request has been blocked; the content must be served over HTTPS.
Run Code Online (Sandbox Code Playgroud)
我的问题:有没有办法强制反向生成HTTPS URL而不是HTTP?
这是一段代码,从HTTPS URL到HTTP的重定向存在问题:
class IndexRedirectView(RedirectView, CSRFExemptMixin):
permanent = False
def get_redirect_url(self, *args, **kwargs):
if self.request.user.visit_count >= 5:
return reverse('gift-shop')
if len(BaseGiftableInstance.objects.filter(giving_user=self.request.user)) > 0:
# has won something
return reverse('gift-shop')
return reverse('spinner')
Run Code Online (Sandbox Code Playgroud)