【问题标题】:python django framewExpected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>`python django framew期望从视图返回一个`Response`、`HttpResponse`或`HttpStreamingResponse`,但收到了`<class 'NoneType'>`
【发布时间】:2021-12-02 17:19:59
【问题描述】:
def post(self,request):
    try:
        profile_image=request.FILES['profile_image']
    except:
        profile_image=""

    full_name=request.data.get('full_image')
    email=request.data.get('email')
    mobile_number=request.data.get('mobile_number')
    gender=request.data.get('gender')

    print(is_alcoholic)
    dob=request.data.get('dob')
    country=request.data.get('country')
    state=request.data.get('state')
    city=request.data.get('city')
    

【问题讨论】:

    标签: python django


    【解决方案1】:

    如果 Python 函数不执行 return something 语句以返回 something,则返回 None

    这个视图从末尾掉下来,默认返回None

    通常返回redirect,以指定浏览器接下来向用户显示的内容。

    【讨论】:

      猜你喜欢
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2019-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2021-09-01
      相关资源
      最近更新 更多