代码之家  ›  专栏  ›  技术社区  ›  MistyD Harish Kumar Kailas

Django-Site.objects.get_current().domain返回example.com

  •  1
  • MistyD Harish Kumar Kailas  · 技术社区  · 6 年前

    我现在有一个Django应用程序在Amazon EC2上运行。我的Django应用程序中有这段代码

     if not 'request' in self.context:
            #In case we dont have a context
            current_site = Site.objects.get_current().domain
            ret['employer_image'] = current_site + ret['employer_image']
    

    现在 Site.objects.get_current().domain 正在返回 example.com 有什么建议可以告诉我们为什么要返回example.com吗?我可以一直硬编码的网址,但我想知道为什么这是失败的?

    0 回复  |  直到 6 年前