django redirect to view

前端 未结 3 368
误落风尘
误落风尘 2021-01-03 19:19

I have one view that I want to do some stuff in and then redirect to another view with a success message. The signature of the method that I want to redirect to is

相关标签:
3条回答
  • 2021-01-03 19:32

    You should Refer this https://docs.djangoproject.com/en/1.11/topics/http/shortcuts/#redirect

    For redirect inside view. Its very easy either you redirect using creating a url for view or call inside the view also.

    0 讨论(0)
  • 2021-01-03 19:40

    Can you try example 2 given in https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect

    • Make sure that it does the 'reverse' on the given view.
    • Your view name should be wrapped in single quotes/
    0 讨论(0)
  • 2021-01-03 19:49

    You haven't given your URL a name, so you need to use the whole path to the view function. Plus, that URL doesn't take errorMessage or successMessage parameters, so putting them into the reverse call will fail. This is what you want:

    return redirect('quizzes.views.quizView', quizNumber=quizNumber)
    
    0 讨论(0)
提交回复
热议问题