如何使用石墨烯突变信息访问Django请求

时间:2020-11-09 03:41:06

标签: django graphene-django

我收到此错误“ WSGIRequest”对象没有属性“ request”

PS:片段被截断了。错误来自info.context.request

  class Arguments:
    input = ForgotPasswordInput()

  ok = graphene.Boolean()
  message = graphene.String()

  @staticmethod
  def mutate(root, info, input=None):
    try:
      user = User.objects.get(email=input.get('email'))
      current_site = get_current_site(info.context.request)```

1 个答案:

答案 0 :(得分:1)

info.context 本身就是 request 对象。所以应该是

current_site = get_current_site(info.context)
                               ^^^^^^^^^^^^^^