Answer the question
In order to leave comments, you need to log in
HttpResponseRedirect in Django - how to solve the problem?
In general, I faced such a problem. Programming in Python with Django 1.4, I can't find the docs on the HttpResponseRedirect function. The question arose whether it is possible, as in PHP, to redirect to the page and send a message about it when an error occurs.
For example:
I have a database of users who are pulled from the database by id. The user tries to enter a non-existent id and immediately redirects to his page with an error message that there is no such user.
Code example:
@login_required
def show_user_id(request, user_id):
user = user_id
for row in django_couch.db().view('users/list_id', key=user).rows:
return render_to_response('show_users_id.tpl', {
'user': row})
else:
return HttpResponseRedirect('/user/')
Answer the question
In order to leave comments, you need to log in
The redirect will not help you in any way in the output of the error. Use messages framework .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question