Django redirect () not working

User: User submits a form with data for Entry A

by url /entry/1

and then transferred to the same form but for Entry B

at url /entry/2

- at this point the form is being submitted to the same view and i am trying to redirect to the next record.

Problem: The redirect just doesn't work, my view function is defined as:

def editor(request, entry_id):


In the view, I am processing post data and used the following lines to redirect:

  • redirect('myapp.views.editor', entry_id=next_id)

  • redirect('myapp.views.editor', kwargs={ 'entry_id': next_id })

  • redirect('/entry/{0}'.format(next_id))

  • HttpResponseRedirect('/entry/{0}'.format(next_id))

What I know:

  • The shortcut redirect

    works in other views
  • next_id

    correct and definitely matters
  • The code is technically valid - it doesn't work silently
  • Trying to redirect to another view doesn't work.

Am I missing something obvious?


source to share

1 answer

You just skipped the tutorial return

. So add it:

return HttpResponseRedirect('/entry/{0}'.format(next_id))




All Articles