【问题标题】:Tastypie - redirect user to new urlTastypie - 将用户重定向到新网址
【发布时间】:2012-07-18 16:22:23
【问题描述】:

我有一个资源,如果用户经过身份验证,它会返回一个 json,否则它将用户重定向到不同的 url。

有人知道我是否可以在 Tastypie 中这样重定向吗?

或者我需要实现某种中间件吗?

提前致谢

【问题讨论】:

    标签: python django tastypie


    【解决方案1】:

    this 开头,如果super 不返回True,则返回重定向响应

    resp = super(...)
    if resp != True:
       resp = self.createresponse(HttpRedirect(SOME_URL))
    return HttpResponseRedirect(redirect_to)
    

    【讨论】:

    • 你在这里的意图不是很清楚。我认为您应该解释并至少为您的代码提供更多上下文。
    猜你喜欢
    • 2016-09-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 2019-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    相关资源
    最近更新 更多